Android 支持库 23.2.0 导致工具栏箭头为黑色

Android Support Library 23.2.0 causing Toolbar arrow to be black

我最近将 Android 支持库昨天更新到了 23.2.0

版本

突然之间,所有 Lolipop 之前的设备都将后退箭头、汉堡包和(三点菜单)的颜色更改为黑色。当他们总是白色的时候。

Lollipop 设备似乎还不错。

这是我的 style.xml,更新之间根本没有编辑。

<?xml version="1.0" encoding="utf-8"?>
<resources>    
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/primaryColor</item>
        <item name="colorPrimaryDark">@color/primaryColorDark</item>
        <item name="colorAccent">@color/accentColor</item>
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppTheme.Base">
    </style> 

    <!-- Theme to customise the tool bar -->
    <style name="MyCustomToolBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="textColorPrimary">@color/textColorWhite</item>
    <!-- Added this now to test, still nothing --!> 
    <item name="colorControlNormal">@color/textColorWhite</item>

    </style>

    <style name="MyApp.MyCustomToolBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
        <!--to add-->
    </style>
</resources>

然后这是我的工具栏布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="@dimen/toolbar_height"
    android:background="@color/primaryColor"
    app:theme="@style/MyCustomToolBarTheme"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark">
</android.support.v7.widget.Toolbar>

我认为您在样式名称="MyCustomToolBarTheme" 中使用了 parent="ThemeOverlay.AppCompat.Dark.ActionBar",将其更改为 Light 主题可能有效...

因为您将此样式用于您的工具栏 app:theme="@style/MyCustomToolBarTheme"

尝试修改后再检查...

这是一个 AppCompat 错误。要解决此问题,请更新 gradle 以使用矢量绘图:

// Gradle Plugin 2.0+  
android {  
    defaultConfig {  
         vectorDrawables.useSupportLibrary = true  
    }  
}

早些时候 gradle:

// Gradle Plugin 1.5  
android {  
  defaultConfig {  
    generatedDensities = []  
 }  

 // This is handled for you by the 2.0+ Gradle Plugin  
 aaptOptions {  
   additionalParameters "--no-version-vectors"  
 }  
}  

编辑:您不再需要根据Android blog设置标志。这已在 23.2.1 中修复。

For AppCompat users, the flags for enabling support vector drawables described in the 23.2 blog post are no longer required for usage of AppCompat. However, you can still take advantage of the app:srcCompat attribute if you wish to use support vector drawables for your own resources.

现在的解决方案:更新您的支持库以使用 23.2.1 或更高版本,如下所示:

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.1'
}

我遇到了同样的问题,现在看来这个错误已通过支持库 23.2.1+ 修复。所以你可以只更新 Android 支持库并在 build.gradle

中更改你的 appcompat 修订号
dependencies {
    compile 'com.android.support:appcompat-v7:23.2.1'
}