Sunday, August 9, 2015

How to set CheckBox on the right side of text in Android

activity_main.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    tools:context=".MainActivity"
    android:background="#c0be7a"
    >
    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Check your favorites."
        />
    <CheckBox
        android:id="@+id/cb_coldfusion"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ColdFusion"
        android:layout_below="@id/tv"
        android:button="@null"
        android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
        />
    <CheckBox
        android:id="@+id/cb_flex"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Flex"
        android:layout_below="@id/cb_coldfusion"
        android:button="@null"
        android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
        />
</RelativeLayout>
More android examples