A p A p - 5 months ago 59
Android Question

How to align check box on the right side in CheckedtextView

I have an XML layout and I want to make the CheckBox align to the right side.

Only the CheckBox should be on the right side not the text.

How can I do that?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">


<CheckedTextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"/>
</LinearLayout>

Answer

Following code is working for me

 <CheckedTextView
    android:id="@+id/checkedTextView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:textColor="#000000,"
    android:layout_marginTop="48dp"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
    android:checked="true"
    android:text="CheckedTextView" />