Android 元素之间的操作栏填充:

Android 元素之间的操作栏填充:,android,android-actionbar,Android,Android Actionbar,我试图在操作栏中的项目之间添加填充物-特别是我的徽标和导航抽屉图标,以下是我使用的样式: <resources> <!-- the theme applied to the application or activity --> <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:

我试图在操作栏中的项目之间添加填充物-特别是我的徽标和导航抽屉图标,以下是我使用的样式:

<resources>

    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@android:color/transparent</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:icon">@drawable/logo_header</item>
        <item name="android:actionButtonStyle">@style/MyActionButtonStyle</item>
    </style>

    <style name="MyActionButtonStyle" parent="@android:style/Widget.ActionButton">
        <item name="android:minWidth">32dip</item>
        <item name="android:padding">12dp</item>
    </style>

</resources>

@样式/MyActionBar
@android:彩色/透明
真的
@可抽出式/标志式头部
@样式/MyActionButtonStyle
32dip
12dp
但是,这两种方法似乎不起作用:

<item name="android:minWidth">32dip</item>
<item name="android:padding">12dp</item>
32dip
12dp

你知道我在这里遗漏了什么吗

我认为正确的语法应该是:

<item
...
android:layout_padding="12dp"
...
/>

我会将徽标制作成一个可绘制的图层列表,这样我可以将其填充设置为如下所示:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:drawable="@drawable/my_main_icon"
        android:right="20dp"/>

</layer-list>

如果您使用此图标,请更新您的清单,将此可绘制图标用作主图标,而不是当前图标

更新:根据stackOverFlow上的阅读,最好使用此图标作为徽标。
所以在你的应用程序标签清单中设置android:logo=“my_main_icon”,仍然在研究这个问题

更新:如果你使用logo,我想你必须在actionbar中打开它

setDisplayUseLogoEnabled()允许使用替代图像(a “徽标”),而不是默认的应用程序图标。A. 徽标通常是一个更宽、更详细的图像,代表 应用


如果您在设备上使用jelly bean或up,请转到“开发人员选项”并启用“显示布局边界”。这可能会帮助您更好地查看页边距。谢谢,我将尝试不,没有关联的列表视图,我指的是操作栏中的标准按钮和图标。是的,很抱歉,我误解了这里的某些内容。。但我只是编辑了答案:DCheers,没有太大区别:)它不是这样工作的吗?“12dp”的语法似乎太错误了。是的,有一些问题最终导致使用填充图像视图!