如何在android中的菜单项之间添加填充? [英] how to add padding between menu items in android?

查看:26
本文介绍了如何在android中的菜单项之间添加填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的菜单项从 res/menu/menu.xml 扩展到 ActionBar,如何使用 android 在菜单项之间添加填充?

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 文件:

@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;
}

推荐答案

找到解决方案,在styles.xml 文件中添加了以下几行并且成功了!!

Found solution, added following lines in styles.xml file and it worked!!

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionButtonStyle">@style/MyActionButtonStyle</item>
</style>

<style name="MyActionButtonStyle" parent="AppBaseTheme">
    <item name="android:minWidth">20dip</item>
    <item name="android:padding">0dip</item>
</style>

这篇关于如何在android中的菜单项之间添加填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆