colorPrimary不适用于android 4.0及以上版本中的android.support.v7.widget.Toolbar

colorPrimary不适用于android 4.0及以上版本中的android.support.v7.widget.Toolbar,android,themes,android-toolbar,android-appcompat,Android,Themes,Android Toolbar,Android Appcompat,我使用工具栏作为操作栏并设置背景色。我可以在旧版本的设备上看到彩色工具栏,但在4.0及更高版本上,它显示为透明的黑色 我已经像这样设置了工具栏小部件 <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" androi

我使用工具栏作为操作栏并设置背景色。我可以在旧版本的设备上看到彩色工具栏,但在4.0及更高版本上,它显示为透明的黑色

我已经像这样设置了工具栏小部件

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

</android.support.v7.widget.Toolbar>

并在styles.xml中设置应用程序的主题,如下所示\

   <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/primaryColor</item>
    <item name="colorPrimaryDark">@color/primaryColorDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

@颜色/原色
@颜色/原色深色
@颜色/口音
真的
假的
@样式/抽屉箭头样式

你可以节省时间,用
android:background=“?attr/colorPrimary”
替换
android:background=“#FFFFFF”
primaryColor和primaryColorDark必须是不同的@color/primaryColor中有什么?我假设你确定你没有覆盖
AppBaseTheme
中的任何
值-v[14等]
文件夹?