jeudi 13 août 2015

Align checkbox to the right side in LinearLayout android

I am trying to make some text views with checkboxes in LinearLayout. I want for result like this:

TextView           Ckeckbox
TextViewwwwww      Ckeckbox
TextV              Ckeckbox

But currently i have this:

TextView  Ckeckbox
TextViewwwwww  Ckeckbox
TextV  Ckeckbox

Here is my xml:

<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:orientation="horizontal">

  <TextView
    android:id="@+id/itemTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
 <CheckBox
        android:id="@+id/checkItem"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />
</LinearLayout>

And this xml gives me same result:

<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:orientation="horizontal">

  <TextView
    android:id="@+id/itemTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="start"/>
 <CheckBox
        android:id="@+id/checkItem"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"/>
</LinearLayout>




Aucun commentaire:

Enregistrer un commentaire