<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="6dp"
android:weightSum="1.0" >
<Button
android:id="@+id/btnCreateNewMonth"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center"
android:layout_weight="0.5"
android:onClick="btnCreateNewMonth_clickHandler"
android:paddingBottom="5dp"
android:text="@string/btn_create_new_month" />
<Button
android:id="@+id/btnLoadExistingMonth"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center"
android:layout_weight="0.5"
android:onClick="btnLoadExistingMonth_clickHandler"
android:text="@string/btn_load_existing_month" />
</LinearLayout>
The padding should be 6dp for all sides. But at the top , between app title and layout there is a smaller padding?! What’s the solution for that ??
Thanks.
The problem is not with the padding,
If you look at deep on the layout you can see the difference of the button occupied areas and the layout areas.
Background source for the Button is not fully occupied the spaces in Right,Left,Bottom corners.
But the Background source of the Button has been covered and fully occupied in the top.
Note the Background source of the Button is a 9 patch image with transparent background.
In this case , for example if the Gap which is not occupied by the Background source of the button is 2dp means,
Right , Left, Bottom there will be a extra 2dp spaces. But not in the Top.
So with the padding of 6dp you will be get extra background visibility of 2dp for both buttons in the Right,Left,Bottom corners.
so if your padding value is 6dp , then your layout background visibility will be 8dp in the Right,Left,Bottom corners and 6dp in the top.
This is the actual problem.
If you change the background color of the button , you can see the even padding values for all 4 corners.
If you are going to create image background for the button then it should be equally created , unlike the android default button background.
So the solution is , you can create a gradient background for your buttons or you can create a new image file for your buttons.
Hope you get it and it will be useful tip for you.