I want to lay two TextView to the left, and one button to the right inside a linear layout, is this possible? The following is my code where I had to hardcode the leftMargin of the button, this is inflexible. Is it possible to layout children that flows in different directions?
<LinearLayout
android:id="@+id/widget43"
android:layout_width="fill_parent"
android:layout_height="100px"
>
<TextView
android:id="@+id/tc_buttom_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time elapsed"
>
</TextView>
<TextView
android:id="@+id/tc_buttom_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00:00 00"
>
</TextView>
<Button
android:id="@+id/tc2_home"
android:layout_width="70px"
android:layout_height="wrap_content"
android:layout_marginLeft="200px"
android:layout_marginRight="10px"
android:text="Home"
android:layout_weight="0.5"
>
</Button>
</LinearLayout>
I want to lay two TextView to the left, and one button to the right inside a linear layout, is this possible?
Not with a single LinearLayout
. You either need two LinearLayout
s (one for a column of two TextView
s on the left), or one RelativeLayout.
Is it possible to layout children that flows in different directions?
If by "different directions" you mean both vertical and horizontal simultaneously, a single LinearLayout
can only go in one direction. Either use nested LinearLayout
s or a RelativeLayout
.