如何更改Android溢出菜单图标

new*_*dev 16 android android-3.0-honeycomb

如何更改操作栏最右侧的"溢出菜单"图标,如下图所示?我的Holo主题默认指定这个3行黑色堆栈图标,我想要别的东西.我似乎找不到解决方案.我查看了http://developer.android.com/guide/topics/ui/menus.html上的文档,但它似乎没有提供太多帮助.

谢谢!

小智 28

你可以尝试这样的事情:

<style name="MyTheme" parent="android:style/Theme.Holo.Light">
     <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
</style>

<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow">
    <item name="android:src">@drawable/my_action_bTutton_overflow</item>
</style>
Run Code Online (Sandbox Code Playgroud)

并在AndroidManifest.xml中

<application
    android:theme="@style/MyTheme" >
Run Code Online (Sandbox Code Playgroud)


Kar*_*som 20

定义自定义样式:例如,让我们调用它customoverflow.

在此样式中,您可以设置android:src要使用的图片.现在用parent创建一个样式Theme.holo.

在这种风格中你需要定义:

<item name="android:actionOverflowButtonStyle">@style/customoverflow</item>
Run Code Online (Sandbox Code Playgroud)

我只是测试了它,它的工作原理.

  • 它不够可定制.假设你有一个带有黑色溢出按钮的浅色背景.如果为动作模式(CAB)选择深色背景,则无法将溢出按钮切换为轻按钮. (2认同)

DjP*_*DjP 10

如果您使用的是AppCompat,则可以通过以下代码实现.

RES /值/的themes.xml

<style name="MyTheme" parent="@style/Theme.AppCompat.Light">
     <item name="android:actionOverflowButtonStyle">@style/ActionButtonOverflow</item>

      <!-- Support library compatibility -->
     <item name="actionOverflowButtonStyle">@style/ActionButtonOverflow</item>

</style>

      <style name="ActionButtonOverflow" parent="@style/Widget.AppCompat.ActionButton.Overflow">
            <item name="android:src">@drawable/ic_launcher</item>
        </style>
Run Code Online (Sandbox Code Playgroud)

并在androidmanifest.xml中

<application
    android:theme="@style/MyTheme" >
Run Code Online (Sandbox Code Playgroud)

  • 非常适合指出支持库的兼容性差异 (2认同)