更改ActionBarSherlock背景颜色 [英] Change ActionBarSherlock background color

查看:135
本文介绍了更改ActionBarSherlock背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现ActionBarSherlock,因为我被告知这是比较容易实现和定制。我发现这是pretty的容易实现,但我试图改变动作条的背景颜色和它的证明很难。

I'm trying to implement ActionBarSherlock because I was told it is relatively easy to implement and customize. I've found it was pretty easy to implement, but I'm trying to change the background color of the ActionBar and it's proving difficult.

据该网站(链接),似乎可以继承的ActionBarSherlock的主题之一,​​然后覆盖的属性您所需要的。

According to the the site (link), it seems you can inherit one of the ActionBarSherlock's themes and then override the properties you need.

这是我到目前为止有:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="Theme.ActionBar" parent="Theme.Sherlock.ForceOverflow">
      <item name="android:background">#000000</item>
      <item name="background">#000000</item>
    </style>
</resources>

我注意到了内置的主题使用的图像为背景,但我祈祷我没有创建图像,改变背景颜色。

I'm noticing the built-in theme are using images for the background, but I'm praying I don't have to create images to change the background color.

感谢。

推荐答案

操作栏的背景色是为操作栏,而不是在主题本身的样式定义。你需要做的是这样的:

The action bar background color is defined in a style for the action bar, not in the theme itself. You'll need to do something like this:

<style name="Theme.MyTheme" parent="Theme.Sherlock.ForceOverflow">
    <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
</style>

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

要小心使用XML定义的颜色。 Col​​orDrawable 不尊重它是在pre-蜂窝视图边界,所以如果你使用的标签导航与堆叠标签视图中,您将有问题的一个单独的背景。

Be careful using colors defined in XML. ColorDrawable did not respect it's view bounds on pre-Honeycomb so if you use tab navigation with a separate background for the stacked tab view you will have problems.

这篇关于更改ActionBarSherlock背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆