android - Material Design中的colorPrimary属性不起作用
阿神
阿神 2017-04-17 16:13:34
0
1
693
<style name="AppTheme" parent="android:Theme.Material.Light">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="android:statusBarColor">@color/colorPrimaryDark</item>
    <item name="android:textColorPrimary">@color/colorAccent</item>
    <item name="android:windowBackground">@color/colorWindowBackground</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

</resources>
上面是我在项目里引入Material主题的代码,我想自己设置一下ActionBar的背景色,但发现这属性没起作用?有知道原因的吗?谢谢!
阿神
阿神

闭关修行中......

reply all(1)
左手右手慢动作
     <style name="AppTheme" parent="android:Theme.Material.Light">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="android:statusBarColor">@color/colorPrimaryDark</item>
        <item name="android:textColorPrimary">@color/colorAccent</item>
        <item name="android:windowBackground">@color/background</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

You posted the above, I tried it and it works. . The following is the official document

 <style name="AppTheme" parent="android:Theme.Material.Light">
        <item name="android:colorPrimary">@color/colorPrimary</item>
        <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="android:colorAccent">@color/colorAccent</item>
    </style>

ActionBar is defined by the android:colorPrimary attribute, please check again
Also, the color of the status bar is best to use the android:colorPrimaryDark attribute

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template