Divide LinearLayout in android in two sections or parts
Just like in WPF, in android we need to divide LinearLaoyout in two columns, but there are no column in xml so how can we do it? Here is the simple solution. All you need to take care of
android:layout_weight
and nothing else
here I am posting a code snippet there are two buttons in a linear layout and you can modify id according to your controls.
<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"> <Buttonandroid:id="@+id/button_add_other_location"style="?android:textAppearanceSmall"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1" android:text="Add location" /> <Buttonandroid:id="@+id/button_continue"style="?android:textAppearanceSmall"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1"android:text="Continue" /> </LinearLayout>
Look at the highlighted code this is it it will divide your LinearLayout into two halfs.
Happy coding..........
No comments: