[英]Cannot change color of actionbar with appcompact v7 and Android Studio 1.1 Preview
我尝试了多种样式来更改操作栏的颜色,但没有用。
这是我的风格:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="actionBarStyle">@style/AppTheme.ActionBarStyle</item>
</style>
<style name="AppTheme.ActionBarStyle" parent="Widget.AppCompat.ActionBar.Solid">
<item name="android:background">#f01234</item>
</style>
我的模拟器版本:Android 4.2
在SupportV7
版本21中更改ActionBar
颜色使用colorPrimary
属性
像这样:
<style name="_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="colorAccent">@color/white</item>
<item name="android:textColorPrimaryInverse">@android:color/white</item>
<!--<item name="android:actionBarStyle">@style/ActionBarStyle</item>-->
</style>
在styles.xml中:
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#eeeeee</item>
</style>
并在Manifest.xml中:
<activity
android:name="yourPackage.MainActivity"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我希望能对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.