我的案例中的操作栏自定义样式

Lee*_*fin 2 android android-widget android-intent android-layout android-actionbar

我正在使用Android原生动作栏.我想添加自己的drawable资源作为操作栏的背景.所以,我做了一个如下主题:

res/values/themes.xml:

<style name="Theme.MyStyle" parent="android:style/Theme.Holo.Light">
    <item name="android:background">@drawable/my_bg</item>
</style>
Run Code Online (Sandbox Code Playgroud)

然后,在AndroidManifest.xml文件中,我将此样式添加到我的应用程序:

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

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

</application>
Run Code Online (Sandbox Code Playgroud)

,背景绘制应用于NOT ONLY行动吧,还对所有碎片的内容.为什么?

我的第二个问题是,如何自定义溢出图标和操作栏上最左侧的"向上"按钮?

Jua*_*vas 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>
Run Code Online (Sandbox Code Playgroud)

使用自定义徽标setDisplayUseLogoEnabled(boolean)

更多信息