Android:更改操作栏的颜色
我以前将窗口背景的颜色设置为白色,现在我正在尝试将操作栏的颜色更改为绿色。这是我的xml代码:Android:更改操作栏的颜色,android,xml,colors,android-actionbar,customization,Android,Xml,Colors,Android Actionbar,Customization,我以前将窗口背景的颜色设置为白色,现在我正在尝试将操作栏的颜色更改为绿色。这是我的xml代码: <style name = "CustomAppTheme2" parent = "android:Widget.Holo.Light"> <item name="android:windowBackground">@color/white</item> <item name="android:background">@color/gr
<style name = "CustomAppTheme2" parent = "android:Widget.Holo.Light">
<item name="android:windowBackground">@color/white</item>
<item name="android:background">@color/green</item>
<item name="android:icon">@android:color/transparent</item>
</style>
@颜色/白色
@颜色/绿色
@android:彩色/透明
问题是,使用android:background更改操作栏的颜色时,会溢出并将整个屏幕的颜色更改为绿色。我想要一个清晰的绿色动作条,下面有一个白色的窗口。提前谢谢
<!-- Base application theme. -->
<style name="AppTheme" parent="@style/CustomActionBarTheme">
<!-- Customize your theme here. -->
</style>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- Support library compatibility -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/top_bar_blue</item>
<!-- Support library compatibility -->
<item name="background">@drawable/top_bar_blue</item>
<item name="titleTextStyle">@style/myTheme.ActionBar.Text</item>
</style>
<!-- ActionBar Text -->
<style name="myTheme.ActionBar.Text" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
<item name="android:fontFamily">sans-serif-bold</item>
</style>
<!-- In Manifest -->
android:theme="@style/AppTheme"
@样式/MyActionBar
@样式/MyActionBar
@可拉拔/顶杆\蓝色
@可拉拔/顶杆\蓝色
@style/mysteme.ActionBar.Text
@android:彩色/白色
20便士
大胆的
无衬线粗体
android:theme=“@style/AppTheme”
您可以从一个类中扩展ActionBarActivity
,并执行以下操作:
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
//Change the color of the actionbar by changing the value in the next line
actionBar.setBackgroundDrawable(new ColorDrawable(#FFFFFF));
请检查此问题的已接受答案。如果有效,请接受我的答案,并投票:)非常感谢。向上提我的问题,这样我就可以向上提你的答案:)谢谢你的帮助!请回答我的问题,这样我才能回答你:)