This question already has an answer here:
I'm having menu items being inflated from res/menu/menu.xml on to ActionBar, how do I add padding between menu items using android?
<item
android:id="@+id/home"
android:showAsAction="always"
android:title="Home"
android:icon="@drawable/homeb"/>
<item
android:id="@+id/location"
android:showAsAction="always"
android:title="Locations"
android:icon="@drawable/locationb"/>
<item
android:id="@+id/preQualify"
android:showAsAction="always"
android:title="Pre-Qualify"
android:icon="@drawable/prequalityb"/>
<item
android:id="@+id/products"
android:showAsAction="always"
android:title="Products"
android:icon="@drawable/productb"/>
Java file:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_store_locator, menu);
return true;
}
Found solution, added following lines in styles.xml file and it worked!!
create drawable xml . like
res/drawable/shape_green_rect.xml
Add this drawable in
This way we can able to add padding in menu.
Thanks.
Padding I don't know, but you can add margin by the following way:
Set your values instead of "left, top, right, bottom". In this example I'm adding margin on an item that you would get with its ID.
Hope this helps.