Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

android - Change ActionBar Tabs background color

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.

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?

I'm using ActionBarSherlock btw

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...