在我的情况下,操作栏自定义样式 [英] Action bar custom style in my case
问题描述
我使用Android原生操作栏。我想补充我自己绘制资源作为操作栏的背景。所以,我做了一个主题,像下面这样:
I am using Android native action bar. I would like to add my own drawable resource as the background of the action bar. So, I made a theme like following:
RES /价值/的themes.xml:
<style name="Theme.MyStyle" parent="android:style/Theme.Holo.Light">
<item name="android:background">@drawable/my_bg</item>
</style>
然后,在 AndroidManifest.xml中文件我添加这种风格到我的应用程序:
Then, in AndroidManifest.xml file I add this style to my application:
<application
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyStyle"
>
<activity ...>
<activity .../>
...
</application>
但,背景绘制应用的不仅即可操作栏的也以所有的碎片的内容。为什么呢?
BUT, the background drawable is applied NOT ONLY to action bar BUT ALSO to all fragments' content. why?
我的第二个问题是,如何自定义的溢图标和最左面的向上的行动吧??按钮
My 2nd question is, how to customize the overflow icon and the left-most "up" button on action bar??
推荐答案
尝试
<?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>
<一个href="http://developer.android.com/reference/android/app/ActionBar.html#setDisplayUseLogoEnabled%28boolean%29">customize标志使用 setDisplayUseLogoEnabled(布尔)
这篇关于在我的情况下,操作栏自定义样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!