2012-11-05 61 views
3

我使用ActionBarSherlock并已申请自定义他们改变操作栏的外观:ActionBarSherlock自定义主题被忽略

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

<style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar"> 
    <item name="android:background">@drawable/background_action_bar</item> 
    <item name="android:icon">@drawable/image_action_bar_logo</item> 
</style> 

这工作完全在设备上运行果冻豆,但是当我部署运行2.2或2.3的模拟器将忽略自定义操作栏样式,并使用默认样式。

任何想法?

感谢 大卫

回答

6

你必须调整的主题和一点点:

<style name="Theme.MyTheme" parent="@style/Theme.Sherlock"> 
    <!-- define the style for ActionBarSherlock --> 
    <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item> 

    <!-- define the style for native ActionBar for Android 4 and higher --> 
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item> 
</style> 

编辑:

而且还适当调整了风格:

<style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar"> 
    <!-- for ActionBarSherlock --> 
    <item name="background">@drawable/background_action_bar</item> 
    <item name="icon">@drawable/image_action_bar_logo</item> 

    <!-- for native ActionBar for Android 4 and higher --> 
    <item name="android:background">@drawable/background_action_bar</item> 
    <item name="android:icon">@drawable/image_action_bar_logo</item> 
</style> 
+1

谢谢,我还需要为没有android名称的背景和图标项目重复条目步伐。 – user648462

+0

对,我将它添加到答案中。 – Tomik

相关问题