samedi 29 juillet 2017

Android: Programmatically set checkbox set text position on the right

How can I set a programmatically created checkbox's text to be aligned on the left instead of right side of the checkbox. Below is a code snippet:

                            Checkbox check1 = new Checkbox(getApplicationContext());
                            check1.setLayoutParams(new ActionBar.LayoutParams(LinearLayoutCompat.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
                            check1.setId(fieldNo);
                            check1.setTextColor(Color.BLACK);
                            check1.setGravity(Gravity.RIGHT);
                            check1.setText(formField.get(fieldNo));

The above code resulted in the text shown on the right of the checkbox.

Here is a screenshot : enter image description here

How can I have the text on the left of the checkbox?




Aucun commentaire:

Enregistrer un commentaire