Linear Layout and weight in Android
Posted
by Janusz
on Stack Overflow
See other posts from Stack Overflow
or by Janusz
Published on 2010-04-23T13:18:23Z
Indexed on
2010/04/23
13:23 UTC
Read the original article
Hit count: 629
I always read about this funny weight value in the Android documentations. Now I want to try it for the first time but it isn't working at all.
As I understand it from the documentations this layout:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:text="Register"
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
weight="1" />
<Button
android:text="Not this time"
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
weight="1" />
</LinearLayout>
should create two buttons that are horizontally aligned and share the space equally. The problem is the two buttons don't grow to fill the space. The result is something like this:
I would like the buttons to grow and fill the whole line.
© Stack Overflow or respective owner