I'm trying to setup a layout of 6 buttons in the form of 2x3 (w/h) on the screen.
My layout XML is below:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/androidbg"
android:paddingBottom="@dimen/none"
android:paddingLeft="@dimen/none"
android:paddingRight="@dimen/none"
android:paddingTop="@dimen/none"
tools:context=".MainActivity" >
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="4dip"
android:orientation="horizontal" >
<Button
android:id="@+id/btnTopLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/diary"
android:layout_weight="1"
android:background="@drawable/menu_button"
style="?android:attr/buttonBarButtonStyle"
android:onClick="openDiary"
android:padding="4dip" />
<Button
android:id="@+id/btnTopRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/diary"
android:layout_weight="1"
android:background="@drawable/menu_button"
style="?android:attr/buttonBarButtonStyle"
android:onClick="openDiary"
android:padding="4dip" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="4dip"
android:orientation="horizontal" >
<Button
android:id="@+id/btnMidLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/diary"
android:layout_weight="1"
android:background="@drawable/menu_button"
style="?android:attr/buttonBarButtonStyle"
android:onClick="openDiary"
android:padding="4dip" />
<Button
android:id="@+id/btnMidRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/diary"
android:layout_weight="1"
android:background="@drawable/menu_button"
style="?android:attr/buttonBarButtonStyle"
android:onClick="openDiary"
android:padding="4dip" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="4dip"
android:orientation="horizontal" >
<Button
android:id="@+id/btnBottomLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/diary"
android:layout_weight="1"
android:background="@drawable/menu_button"
style="?android:attr/buttonBarButtonStyle"
android:onClick="openDiary"
android:padding="4dip" />
<Button
android:id="@+id/btnBottomRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/diary"
android:layout_weight="1"
android:background="@drawable/menu_button"
style="?android:attr/buttonBarButtonStyle"
android:onClick="openDiary"
android:padding="4dip" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
This XML mostly works as I want it to - with the exception of the android:padding="4dip"
inside the <Button>
tags. This padding seems to be being completely ignored, making the buttons squashed together in the middle.
Below I have provided a crude drawing (behold my paint skills) of the current state of the app on the left - and the intended layout of the app on the right (blue boxes are buttons).
Any ideas how I would be able to pad the buttons apart in the center?