更新到支持库23.2.0之后,棒棒糖前置设备中的后退箭头和溢出图标颜色错误 [英] Back Arrow and Overflow Icons Wrong Color in Pre-Lollipop Devices After Updating to Support Library 23.2.0

查看:100
本文介绍了更新到支持库23.2.0之后,棒棒糖前置设备中的后退箭头和溢出图标颜色错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在棒棒糖之前的设备上,升级到支持库23.2.0后,操作菜单上的溢出菜单图标和后退按钮变为黑色.升级前它们是白色的(正确的颜色).

On pre-Lollipop devices, the overflow menu icon and back button on actionbar changed to black color after upgrading to Support Library 23.2.0. They are white (which is the right color) before the upgrade.

正确的颜色是:

升级后,棒棒糖之前的设备显示错误的颜色,如溢出菜单图标所示:

The wrong color appears for pre-Lollipop devices after the upgrade, as shown with the overflow menu icon:

sytle.xml(v21之前的版本/Lollipop)中的主题:

The theme in sytle.xml (pre-v21/Lollipop):

<resources xmlns:android="http://schemas.android.com/apk/res/android" >
    <!--Used on the application level by the manifest.-->
    <style name="app_theme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/app_primary_colour</item>
        <item name="colorPrimaryDark">@color/app_primary_dark_colour</item>
        <item name="colorAccent">@color/app_accent_colour</item>
        <item name="android:windowBackground">@color/app_background</item>
        <item name="searchViewStyle">@style/custom_search_view_style</item>
    </style>

    <!--Used by activities.-->
    <style name="app_theme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <!--TODO: What are these?-->
    <style name="app_theme.app_bar_overlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="app_theme.popup_overlay" parent="ThemeOverlay.AppCompat.Light" /> ... ... </resources>

我看过这里,但没有解决问题.

I have looked here and here but didn't fix the issue.

更新:另请参见以下Google错误报告:

UPDATE: Also see this Google bug report: https://code.google.com/p/android/issues/detail?id=201918

推荐答案

我可以解决.

我发现AppCompat主题正在使用以下资源作为溢出按钮:abc_ic_menu_overflow_material.xml

I found that AppCompat theme is using following resource for overflow button: abc_ic_menu_overflow_material.xml

此资源的内容是:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?attr/colorControlNormal">
    ...
</vector>

然后,我将点连接起来:

Then, I connected the dots:

  • 首先:它正在使用colorControlNormal
  • 第二:它正在使用向量

如何修复

根据Library V23.2.0发行说明(在此处链接),我们必须更新build.gradle以添加对Vector的支持:

According to Library V23.2.0 Release notes (LINK HERE), we have to update build.gradle to add support to Vector:

build.gradle

将以下行添加到构建gradle

Add following lines to your build gradle

2.0版(我没有测试过):

Gradle 2.0 (I did not tested):

android {  
    defaultConfig {  
        vectorDrawables.useSupportLibrary = true  
    }  
}  

1.5级(我正在使用它.它有效):

Gradle 1.5 (I'm using this.. it works):

android {  
    defaultConfig {  
        generatedDensities = []  
    }  

    aaptOptions {  
        additionalParameters "--no-version-vectors"  
    }  
}  

确定主题

此步骤可以忽略.一些基本主题已经将colorControlNormal设置为白色(例如AppCompat.Dark.ActionBar).

This step may be ignored. Some base themes already set colorControlNormal to white (such as AppCompat.Dark.ActionBar).

但是,就我而言,所有按钮颜色均保持黑色,因此我必须在主题中添加colorControlNormal并用白色覆盖.

However, in my case, all button colors remained black and I had to add the colorControlNormal to my theme and override it with white color.

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="colorControlNormal">@color/white</item>
</styel>

我希望这可以为您提供帮助.

I hope this can help you.

这就是我解决问题的方式.

This was how I fixed my issue.

这篇关于更新到支持库23.2.0之后,棒棒糖前置设备中的后退箭头和溢出图标颜色错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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