Reputation: 2815
I have the layout of my app set to 480dpi wide, and 480/4 is 120. So, if I have 4 buttons at the top of my app, and I set one to 120dpi wide, why does the button take up half the screen?! How can I get buttons to get sized evenly at the top?
Here, I just added 4 buttons at the top:
Then the first two buttons are 120 dpi wide:
Upvotes: 0
Views: 75
Reputation: 4064
Try this
<TableRow android:layout_width="fill_parent"
android:weightSum="100" android:layout_height="wrap_content">
<Button android:text="Button" android:layout_weight="25"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:layout_width="wrap_content"
android:layout_weight="25" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:layout_weight="25"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:layout_weight="25"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</TableRow>
Upvotes: 0
Reputation: 8304
check this out:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
</LinearLayout>
Upvotes: 2
Reputation: 4147
You can use FILL_PARENT parameter for layout width and add a weight 1 to each of your buttons to get desired effect
Upvotes: 1