2

我正在使用Android本機操作欄。我想添加我自己的drawable資源作爲操作欄的背景。所以,我做了一個主題,像以下:我的情況下的動作欄自定義樣式

RES /價值/的themes.xml:

<style name="Theme.MyStyle" parent="android:style/Theme.Holo.Light"> 
    <item name="android:background">@drawable/my_bg</item> 
</style> 

然後,在的AndroidManifest.xml文件我這種風格添加到我的應用程序:

<application 
     android:debuggable="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 

     android:theme="@style/Theme.MyStyle" 
     > 
    <activity ...> 
    <activity .../> 
    ... 

</application> 

但是,背景可繪製應用不只來操作欄但還有所有片段的內容。爲什麼?

我的第二個問題是,如何自定義溢出圖標和操作欄上最左側的「向上」按鈕?

回答

6

嘗試

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <!-- the theme applied to the application or activity --> 
    <style name="Theme.MyStyle" parent="@android:style/Theme.Holo"> 
     <item name="android:actionBarStyle">@style/MyActionBar</item> 
     <!-- other activity and action bar styles here --> 
    </style> 

    <!-- style for the action bar backgrounds --> 
    <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar"> 
     <item name="android:background">@drawable/ab_background</item> 
     <item name="android:backgroundStacked">@drawable/ab_background</item> 
     <item name="android:backgroundSplit">@drawable/ab_split_background</item> 
    </style> 
</resources> 

customize the logo使用setDisplayUseLogoEnabled(boolean)

More info

+0

是的,我也跟着崗位那裏,並且產生的問題,我在這裏問。我更喜歡在我的問題上更具體的回答,而不是再次回到循環。我在製作自定義樣式時沒有問題,問題是我在AndroidManifest.xml中將樣式添加到了我的應用中,但它適用於所有地方,而不僅僅是操作欄。 – 2012-03-02 13:38:19

+0

而我沒有使用我的操作欄上的標籤 – 2012-03-02 13:41:57

+0

我認爲你的問題是在屬性風格的父。嘗試只適用於'「機器人:風格/ Widget.Holo.Light.ActionBar」' – 2012-03-02 13:51:33

相關問題