How to show android checkbox at right side? How to show android checkbox at right side? android android

How to show android checkbox at right side?


I think it's too late to answer this question, but actually there is a way to achieve your goal. You just need to add the following line to your checkbox:

android:button="@null"android:drawableRight="?android:attr/listChoiceIndicatorMultiple"

You can use your customized drawable for checkbox as well.

And for a radioButton:

android:button="@null"android:drawableRight="@android:drawable/btn_radio"

And if you want to do it programmatically:

Define a layout and name it RightCheckBox and copy the following lines :

<?xml version="1.0" encoding="utf-8"?><CheckBox xmlns:android="http://schemas.android.com/apk/res/android"    android:text="hello"    android:layout_width="match_parent"     android:layout_height="match_parent"    android:button="@null"    android:drawableRight="?android:attr/listChoiceIndicatorMultiple"/>

and when you need to add it programmatically you just need to inflate it to a CheckBox and add it to the root view.

CheckBox cb = (CheckBox)((LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.check_right_checkbox,null);rootView.addView(cb);


You can do

<CheckBoxandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="right|center"//or "center_vertical" for center textandroid:layoutDirection="rtl"android:text="hello" />

Following line is enough

android:layoutDirection="rtl"


You can add android:layoutDirection="rtl" but it's only available with API 17.