Maison > Questions et réponses > le corps du texte
<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的背景色,但发现这属性没起作用?有知道原因的吗?谢谢!
ringa_lee2017-04-17 16:15:34
<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>
上面这个是你贴出来的,我试了下,管用。。下面这个是,官方文档的
<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就是android:colorPrimary属性定义的啊,你再检查检查吧
还有就是状态栏的颜色最好是用android:colorPrimaryDark属性吧