更改动作条的标签背景颜色颜色、背景、动作、标签

2023-09-12 21:51:28 作者:三寸海屿日光

有没有办法改变的动作条的标签栏的背景色,而不在一条线的版本改变了吗?

Is there a way to change the background color of the tab bar in the ActionBar without changing it in the one line version?

要澄清我想:在纵向模式下,动作条被分成两行,在动作条本身和下面的选项卡。在横向模式选项卡在实际动作条。

To clarify what I want: In portrait mode the ActionBar is split in two lines, the ActionBar itself and the tabs below. In landscape mode the tabs are in the actual ActionBar.

我想改变纵向模式的背景色。如果我改变背景的TabView的,它会为这两种模式被改变。我一定要创造那些独立的风格?这带来了第二个问题:有没有办法知道什么时候会是两条线,当不

I want to change the background color of the portrait mode. If I change the background in the TabView it'll be changed for both modes. Do I have to create separate styles for those? Which brings up a second question: is there a way to know when it'll be two lines and when not?

或者,我只是失去了一些东西?

Or am I just missing something?

我用ActionBarSherlock顺便说一句

I'm using ActionBarSherlock btw

推荐答案

我认为你正在寻找的安卓backgroundStacked 的动作条的风格属性:

I think you are looking for the android:backgroundStacked attribute of the ActionBar style:

<style name="MyTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
</style>

<style name="MyActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
    <item name="android:backgroundStacked">@drawable/my_stacked_background</item>
</style>

或者(如果使用ActionBarSherlock):

or (If using ActionBarSherlock):

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

<style name="MyActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="android:backgroundStacked">@drawable/my_stacked_background</item>
    <item name="backgroundStacked">@drawable/my_stacked_background</item>
</style>