Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to reduce the spacing between the Action Item Icons on Action Bar?

Tags:

android

I wanted to reduce the spacing bettween Action Item icons added to the ActionBar. Is there a way we can do this?

like image 610
umesh kumar Avatar asked Feb 03 '12 16:02

umesh kumar


People also ask

How do I replace my action bar toolbar?

You'll want to add android:fitsSystemWindows="true" to the parent layout of the Toolbar to ensure that the height of the activity is calculated correctly. When using the support library, make sure that you are importing android. support. v7.

How do you add action items to the action bar in Android?

All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.

What are action bar icons?

The ActionBar, now known as the App Bar, is a consistent navigation element that is standard throughout modern Android applications. The ActionBar can consist of: An application icon. An "upward" navigation to logical parent.


1 Answers

use a custom android:actionButtonStyle.

<item name="android:actionButtonStyle">@style/ActionButtonStyle</item> 

and the magic is here:

<style name="ActionButtonStyle" parent="@android:style/Widget.Holo.Light.ActionButton">     <item name="android:minWidth">0dip</item>     <item name="android:paddingLeft">0dip</item>     <item name="android:paddingRight">0dip</item>                   </style> 

normaly minWidth is set to 56 dip.

like image 163
shai Avatar answered Sep 23 '22 06:09

shai