Android layout AppCompat操作栏背景色
我的Android应用程序中有这个style.xml:Android layout AppCompat操作栏背景色,android-layout,android-activity,android-actionbar,android-styles,android-actionbar-compat,Android Layout,Android Activity,Android Actionbar,Android Styles,Android Actionbar Compat,我的Android应用程序中有这个style.xml: <resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"> <style name="OrangeTheme" parent="@style/Theme.AppCompat"> <item name="android:action
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="OrangeTheme" parent="@style/Theme.AppCompat">
<item name="android:actionBarStyle" tools:ignore="NewApi">@style/OrangeTheme.OrangeActionBar</item>
<item name="android:windowActionBar">true</item>
</style>
<style name="OrangeTheme.OrangeActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">@color/orange</item>
<item name="background">@color/orange</item>
<item name="android:backgroundStacked">@color/orange</item>
<item name="android:backgroundSplit">@color/orange</item>
<item name="android:titleTextStyle">@style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyAppTheme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/black</item>
</style>
我试图不使用AppCompat,但是我的名字有很多错误。它扩展了ActionBarActivity
。如果我将其更改为FragmentActivity
我无法使用getSupportActionBar()
,如果没有它,我的getActionBar()
,总是null
minSdkVersion 19
targetSdkVersion 21
所以现在我无法改变它。我尝试重命名我的样式主题的父级。我尝试使用andrioud:background
和background
。唯一正在改变的是,当我使用另一个像
Theme.App.Compat.Light
或Theme.AppCompat.Light.darkaActionBar
有人知道我如何在运行时更改颜色和其他内容吗?使用新的AppCompat-v7(v21)可以使用新的颜色主题化属性。看
或者,您必须使用
属性(不带前缀android)。要在AppCompat中使用背景色,您还需要在不带android:
属性的情况下定义项目名称
例如:
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:background">@color/action_bar_background</item>
<item name="background">@color/action_bar_background</item> //<--background item without the android attribute
</style>
@颜色/动作\u栏\u背景
@颜色/动作\u栏\u背景//
@样式/MyActionBar
@样式/MyActionBar
希望这有帮助!已经试过了,没用
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:background">@color/action_bar_background</item>
<item name="background">@color/action_bar_background</item> //<--background item without the android attribute
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>