Android 如何更改actionbar(actionbarsherlock)的颜色

Android 如何更改actionbar(actionbarsherlock)的颜色,android,android-layout,android-actionbar,actionbarsherlock,android-xml,Android,Android Layout,Android Actionbar,Actionbarsherlock,Android Xml,如何更改actionbar(actionbarsherlock)的颜色 我在代码下尝试过,但没有运气 <style name="MyTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar"> <item name="background">#ffffffff</item> </style> <style name="Theme.SherlockCustom" parent="@

如何更改actionbar(actionbarsherlock)的颜色

我在代码下尝试过,但没有运气

<style name="MyTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
    <item name="background">#ffffffff</item>
</style>

<style name="Theme.SherlockCustom" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
使用此样式:

<style name="MyTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
      <item name="background">#ffffffff</item>
      <item name="android:background">#ffffffff</item>
</style>

#ffffffff
#ffffffff

我假设您在具有HC或更高版本的设备上测试了应用程序,因为您没有为本机ActionBar指定背景,所以它不起作用。更改上面的样式,它应该会工作。

您第一次发布的内容看起来几乎完全正确,这是更改ActionBar颜色需要添加的主题。您还应该在颜色中添加android:background属性:

<style name="MyTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
    <item name="background">#ffffffff</item>
    <item name="android:background">#ffffffff</item>
 </style>

<style name="Theme.SherlockCustom" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>

#ffffffff
#ffffffff
@style/MyTheme.ActionBarStyle
但是,您需要确保将其应用于整个应用程序,或者仅应用于要在其中显示它的活动。您可以使用android:theme属性在AndroidManifest.xml中的应用程序标记或活动标记中执行此操作

<application
    android:name="com.your.package.name"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/Theme.SherlockCustom" >

我认为您应该使用
@style/Widget.Sherlock.Light.ActionBar.Solid
@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse
作为ActionBarStyle和这两个属性的父级
background
android:background
。例如:

<style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="background">#ffffff</item>
    <item name="android:background">#ffffff</item>
</style>

<style name="Theme.SherlockCustom" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>

#ffffff
#ffffff
@style/MyTheme.ActionBarStyle
@style/MyTheme.ActionBarStyle

可以帮助您设计子菜单的样式。

在设计actionBar的样式时,您最好使用非常流行的web应用程序,它可以让您预览actionBar的外观,并让您下载所有必要的资源,只需将其添加到您的产品中:9patches、state drawables和.xmls

如果你不知道如何使用它,这里有一个快捷的方法


使用此选项可以确保操作栏看起来很棒,而不会浪费大量时间,而这些时间最适合花在有价值的Java代码上

创建自定义操作栏,然后更改操作栏Sherlock的颜色…

创建自定义操作Sherlock栏。。。
 I just used below Code 

 getSupportActionBar().setBackgroundDrawable(new 
   ColorDrawable(Color.parseColor("#00853c"))); 

 it changed the bg color. Hope, it helps.
 I just used below Code 

 getSupportActionBar().setBackgroundDrawable(new 
   ColorDrawable(Color.parseColor("#00853c"))); 

 it changed the bg color. Hope, it helps.