2012-11-05 59 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

相關問題