Android Layout - set the distance between image buttons

I have four buttons on top of the panel (background image). What I'm trying to do is increase the distance between the buttons (so that they are distributed over the strip) and set the gravity value to center_horozontal. I am trying to do paddingLeft and paddingRight on ImageButtons (okcancelbar_button_home), but it does nothing. I think the parent of Buttons images is the key, but I don't know what to install there. Here is my layout:

///////// main .xml ////////////////// <merge xmlns:android="http://schemas.android.com/apk/res/android"> <com.onesix.test.OkCancelBar android:layout_width="fill_parent" android:layout_height="60dip" android:layout_gravity="top" android:paddingTop="0dip" android:gravity="center_horizontal" android:background="@drawable/header_bkgrnd" /> <!--"#AA000000"--> </merge> ////////// okCancelBar //////////////// <merge xmlns:android="http://schemas.android.com/apk/res/android"> <include layout="@layout/okcancelbar_button_home" android:id="@+id/okcancelbar_home" android:layout_height="90dip" /> <include layout="@layout/okcancelbar_button_lists" android:id="@+id/okcancelbar_lists" android:layout_height="90dip" /> <include layout="@layout/okcancelbar_button_calendar" android:id="@+id/okcancelbar_calendar" android:layout_height="90dip" /> <include layout="@layout/okcancelbar_button_search" android:id="@+id/okcancelbar_search" android:layout_height="90dip" /> </merge> ////////////// okcancelbar_button_home //////////////// <?xml version="1.0" encoding="utf-8"?> <ImageButton xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/but_home" android:layout_width="75dip" android:layout_height="60dip" android:layout_alignParentBottom="true" android:background="@android:color/transparent" android:src="@drawable/button_menu_states_home" android:paddingLeft="7dip" android:paddingRight="7dip" /> ////////////button_menu_states_home///////// <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/menu_button_home1_over" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/menu_button_home1_over" /> <!-- focused --> <item android:drawable="@drawable/menu_button_home1" /> <!-- default --> </selector> 
+4
source share
1 answer

Indenting a button increases the size of the actual button. You can think of it as changing the indentation for the button text, not the button itself.

To change the spacing between buttons, you can use the layout_margin attributes (e.g. android:layout_marginLeft = ...).

+18
source

Source: https://habr.com/ru/post/1339690/


All Articles