2012-08-03 86 views
1

我正在使用ActionBarSherlock,並且希望爲其下方的ActionBar和內容視圖使用自定義背景。當我嘗試這一點,背景填充整個屏幕,其中包括動作條:錯誤:找不到與給定名稱匹配的資源:attr'abBackground'

<style name="MyTheme" parent="@style/Theme.Sherlock"> 
    <item name="android:windowBackground">@drawable/background</item> 
</style> 

所以,從this answer,我試圖添加abBackground的主題:

<style name="MyTheme" parent="@style/Theme.Sherlock"> 
    <item name="android:windowBackground">@drawable/background</item> 
    <item name="abBackground">@drawable/bg_button_idle</item> 
</style> 

但是,我得到的錯誤

Error: No resource found that matches the given name: attr 'abBackground'.

這是爲什麼,我該如何解決?

回答

8

這裏是你如何通過改變動作條背景:

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

<style name="MyActionBar" parent="Widget.Sherlock.ActionBar"> 
    <item name="background">@drawable/your_custom_drawable</item> 
    <item name="android:background">@drawable/your_custom_drawable</item> 
</style> 
+2

您還需要一個操作欄風格的'android:background'項目以及ICS +。 – 2012-08-03 17:12:45

0

//沒有abBackground

<item name="abBackground">@drawable/bg_button_idle</item> 

//嘗試

<item name="android:background">@drawable/bg_button_idle</item> 
+1

在整個佈局中使用背景f *,所以這不是一個選項。 – nhaarman 2012-08-03 11:42:32

+0

如果您使用貝尼託回答它不。 – Laranjeiro 2013-04-02 15:49:42

-2

如果該項目是一個庫模塊你應該檢查庫模塊enter image description here

+0

不知道你試圖在這裏說什麼,這肯定不是一個問題 – 2016-01-05 08:58:15

+0

的問題的答案對不起,我通過它是你的主要模塊無法找到你的庫模塊src。 – 2016-05-10 15:15:07

相關問題