I use a simple horizontal LinearLayout to place 3 buttons next to each other, with the same width. I achieve this with the following xml text:
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/activity_vertical_margin" android:baselineAligned="false" > <Button android:id="@+id/help" style="android:buttonBarButtonStyle" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/help" /> <Button android:id="@+id/close" style="android:buttonBarButtonStyle" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/closemultigame" /> <Button android:id="@+id/ok" style="android:buttonBarButtonStyle" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/restartmultigame" /> </LinearLayout>
Now the layout is as follows: 
The layout_height button is defined as wrap_content, but the right-most button does not carry its contents. It looks different on different devices, on some it looks good. What I really would like to achieve is three buttons, the same width and the same height, each with its own text, centered both horizontally and vertically. What approach would you suggest?
ADDED: entire layout on request:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="@dimen/activity_horizontal_margin" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:drawableLeft="@drawable/matchandfit" android:drawablePadding="@dimen/activity_horizontal_margin" android:gravity="center_vertical" android:padding="@dimen/activity_horizontal_margin" android:text="@string/multigameover" android:textAppearance="?android:attr/textAppearanceLarge" /> <TextView android:id="@+id/status" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/multigameresult" android:textAppearance="?android:attr/textAppearanceMedium" /> <LinearLayout android:id="@+id/masterresult" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/masterresultinfo" android:textAppearance="?android:attr/textAppearanceMedium" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/activity_vertical_margin" android:baselineAligned="false" > <Button android:id="@+id/help1" style="android:buttonBarButtonStyle" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="@string/help" /> <Button android:id="@+id/close1" style="android:buttonBarButtonStyle" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="@string/closemultigame" /> <Button android:id="@+id/ok1" style="android:buttonBarButtonStyle" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:text="@string/restartmultigame" /> </LinearLayout> </LinearLayout> </LinearLayout> </ScrollView>
As Vasim Ahmed noted, this is due to ScrollView. Now I use ScrollView to make sure the buttons remain accessible even in the landscape on small devices. (Layout for dialogue). Is there any other way to always keep the buttons accessible / visible?
Workaround: The solution, or the best workaround I have found, is to add a TextView at the end of the included LinearLayout. This TextView is vertically cropped at about half the height, but there is no text in it, so no one will notice. Adding some addition to the bottom of the attached LinearLayout did not help
source share