[英]Changing the colour of ActionBar in Android
Here is my xml code in styles.xml to change theme and colour of ActionBar. 这是我的styles.xml中的xml代码,用于更改ActionBar的主题和颜色。
<?xml version="1.0" encoding="utf-8"?>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">@drawable/brand_logo</item>
<item name="android:background">#ff5d44</item>
</style>
Here is the documentation . 这是文档 。 My app supports API level 11 and higher.
我的应用程序支持API级别11和更高级别。 Not sure where I am going wrong.
不知道我要去哪里错了。 Please help.
请帮忙。
set "AppTheme" as theme for application / activity. 将“ AppTheme”设置为应用程序/活动的主题。
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@android:color/white</item>
</style>
I was using support library. 我正在使用支持库。 So here is the fix.
所以这里是解决方法。
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#ff5d44</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<!--Support library compatibility-->
<item name="background">@color/orange</item>
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.