自定义AppCompat主题不会更改旧设备上的溢出图标 [英] Custom AppCompat Theme not changing Overflow icon on older devices

查看:227
本文介绍了自定义AppCompat主题不会更改旧设备上的溢出图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我决定在我的应用上更改动作溢出图标。我让它在Lollipop设备上工作,但它不适用于我的Ice Cream Sandwich和Kitkat设备。注意:在两个不起作用的设备上,动作溢出图标有3个圆点,因此主题将其更改为Material版本....只是不是我的版本。

Recently I decided to change the Action Overflow Icon on my app. I got it working on Lollipop devices, but it isn't working on my Ice Cream Sandwich and Kitkat device. Note: on both the devices that it does not work on, the action overflow icon has 3 rounded dots, so the theme is changing it to the Material version....just not my version.

我的问题是我无法在旧设备上使用它,但它可以在Lollipop上运行。

My issue is that I cannot get this to work on older devices, but it works on Lollipop.

之前,我不得不单独创建每个版本的主题,但现在不需要。建议只使用一个主题。

Before, I would have had to create separate themes for each version, but now that is not needed. Only one theme is recommended.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="android:actionOverflowButtonStyle">@style/OverflowMenuButton</item>
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <!--<item name="colorPrimaryLight">@color/primary_light</item>-->
        <item name="colorAccent">@color/accent</item>
        <item name="android:textColorPrimaryInverse">@color/primary_text_light</item>
        <item name="android:textColorPrimary">@color/primary_text</item>
        <item name="android:textColorSecondary">@color/secondary_text</item>
        <!--<item name="icons">@color/icons</item>-->
        <item name="divider">@color/divider</item>

    </style>

    <style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
        <item name="android:src">@drawable/ic_star_rate_white_18dp</item>
    </style>


</resources>



正确图标



Correct icon

推荐答案

您正在使用 android:actionOverflowButtonStyle ,这是替换框架溢出按钮的正确方法,仅适用于Lollipop和更高的设备。

You are using android:actionOverflowButtonStyle, which is the correct approach for replacing the framework overflow button, only available on Lollipop and higher devices.

但是,AppCompat有自己的 actionOverflowButtonStyle属性适用于所有API 7+设备 - 您应该使用它来代替 android:actionOverflowButtonStyle

However, AppCompat has its own actionOverflowButtonStyle attribute which works on all API 7+ devices - you should use that in place of android:actionOverflowButtonStyle:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="actionOverflowButtonStyle">@style/OverflowMenuButton</item>

    ...

</style>

这篇关于自定义AppCompat主题不会更改旧设备上的溢出图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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