Android 使用Theme.AppCompat时,操作栏颜色不会更改
我所要做的就是让actionbar和status bar改变颜色以进行材质设计。以下是我创建的主题:Android 使用Theme.AppCompat时,操作栏颜色不会更改,android,android-appcompat,android-theme,Android,Android Appcompat,Android Theme,我所要做的就是让actionbar和status bar改变颜色以进行材质设计。以下是我创建的主题: <!-- Base application theme. --> <style name="AppTheme2" parent="Theme.AppCompat"> <!-- colorPrimary is used for the default action bar background --> <item name="androi
<!-- Base application theme. -->
<style name="AppTheme2" parent="Theme.AppCompat">
<!-- colorPrimary is used for the default action bar background -->
<item name="android:colorPrimary">#FF5722</item>
<!--<item name="android:statusBarColor">#E64A19</item>-->
<!-- colorPrimaryDark is used for the status bar -->
<item name="android:colorPrimaryDark">#E64A19</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="android:colorAccent">#FF9800</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight & colorSwitchThumbNormal. -->
</style>
#FF5722
#E64A19
#FF9800
但是,当运行状态栏时,颜色会变细,但操作栏仍为黑色。我知道可能有一个简单的答案,但我遗漏了什么
这一问题不是所建议问题的重复。请删除标志。从
colorPrimary
删除android:
appcompat-v7
在其主题中没有使用android:
前缀,上次我检查过。从colorPrimary
中删除android:
appcompat-v7
在其主题中没有使用android:
前缀,上次我检查过。既然您使用的是appcompat,那么您应该使用appcompat属性,而不是android系统属性
改变
android:colorPrimary
到
整个事情应该是这样的:
<!-- Base application theme. -->
<style name="AppTheme2" parent="Theme.AppCompat">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#FF5722</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#E64A19</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF9800</item>
</style>
#FF5722
#E64A19
#FF9800
因为您使用的是AppCompat,所以应该使用AppCompat属性,而不是Android系统属性
改变
android:colorPrimary
到
整个事情应该是这样的:
<!-- Base application theme. -->
<style name="AppTheme2" parent="Theme.AppCompat">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#FF5722</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#E64A19</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF9800</item>
</style>
#FF5722
#E64A19
#FF9800
尝试将父主题更改为theme.AppCompat.Light.NoActionBar
的可能副本尝试将父主题更改为theme.AppCompat.Light.NoActionBar
的可能副本