Adil Malik Adil Malik - 5 months ago 10
Android Question

Customizing UI elements in Android

I am naive to Android development. I believe Android Studio is super cool and made life easier but there is something I am stuck with for hours.


I want to make a UI element exactly like shown below. It will contain a person name and check box.

enter image description here

I want to select people and I want in this way.


Please can anyone tell me how to construct this UI element and how to use these elements horizontaly in list view ?

Answer

This will give the same as you expected.

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="David cooper"/>

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView1"
        android:layout_alignParentRight="true"
        android:layout_marginRight="15dp"/>
</RelativeLayout>