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

相关问题