I want to put a TextView on the left-side and a control (eg. a CheckBox) on the right of the TextView. I want the control to be left-aligned on the screen. This is not hard to obtain through a LinearLayout or a RelativeLayout. For example I did this with LinearLayout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/todo_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Small"
android:maxLines="2"
android:textStyle="bold" />
<View
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
<CheckBox
android:id="@+id/todo_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:focusable="false"/>
</LinearLayout>
The problem is that when the TextView's text is too long, it pushes the checkbox out of the screen and the checkbox is no longer visible. Instead, I want that the checkbox is fixed at the right-end of the screen and the TextView eventually split in two lines if necessary. How can I achieve this?