Android 无法使用ActionBarSherlock更改选项卡的背景

Android 无法使用ActionBarSherlock更改选项卡的背景,android,tabs,android-fragments,android-actionbar,actionbarsherlock,Android,Tabs,Android Fragments,Android Actionbar,Actionbarsherlock,我想更改选项卡的背景。在过去的两天里我尝试了所有的方法,所以我决定把我的代码发布在这里。操作栏的背景设置正确,但选项卡保持黑色 <style name="CustomActivityTheme" parent="Theme.Sherlock"> <item name="android:actionBarStyle">@style/MyActionBar</item> <item name="android:actionBarTabSt

我想更改选项卡的背景。在过去的两天里我尝试了所有的方法,所以我决定把我的代码发布在这里。操作栏的背景设置正确,但选项卡保持黑色

  <style name="CustomActivityTheme" parent="Theme.Sherlock">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
    <!-- other activity and action bar styles here -->
</style>

<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="Widget.Sherlock.ActionBar">
    <item name="android:background">@drawable/backgroundactionbar</item>
</style>


<style name="MyActionBarTabStyle" parent="Widget.Sherlock.ActionBar.TabView">
<item name="android:background">@drawable/backgroundactionbar</item>
</style>

@样式/MyActionBar
@风格/风格
@可绘制/背景操作栏
@可绘制/背景操作栏
在舱单上:

         <activity android:name=".FragmentActivityDashboard"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation|screenLayout"
              android:theme="@style/CustomActivityTheme"
              > 
    </activity>

您需要声明两件要更改的事情。android:actionBarStyle和actionBarStyle

<!-- Theme For Tabs and ActionBar Background -->
<style name="Theme.Tabs" parent="Theme.Sherlock">
    <item name="android:actionBarTabStyle">@style/ActionBarTab</item>
    <item name="actionBarTabStyle">@style/ActionBarTab</item>

    <item name="android:actionBarStyle">@style/ActionBarBlank</item>
    <item name="actionBarStyle">@style/ActionBarBlank</item>
</style>

<!-- Styles for the above theme -->
<style name="ActionBarBlank" parent="Widget.Sherlock.ActionBar">
    <item name="android:background">@drawable/tab_bg</item>
    <item name="background">@drawable/tab_bg</item>
</style>

<style name="ActionBarTab" parent="Widget.Sherlock.ActionBar.TabView">
    <item name="android:background">@drawable/bg_tab</item>
    <item name="background">@drawable/bg_tab</item>
</style>

@风格/动作BARTAB
@风格/动作BARTAB
@风格/动作
@风格/动作
@可拉拔/制表符
@可拉拔/制表符
@可绘图/背景选项卡
@可绘图/背景选项卡
请注意,选项卡的可绘制性在xml文件中声明,以指示所选选项卡的单独可绘制性

这是bg_选项卡:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Selected -->
<item android:state_selected="true" android:drawable="@drawable/tab_bg" />

<!-- Normal -->
<item android:drawable="@drawable/transparent" />

</selector>


我终于找到了这个例子。我不明白他们为什么要这么辛苦地做……我同意。这些UI调整中的一些肯定会比现在更容易。