Android 可在背景操作栏中绘制

Android 可在背景操作栏中绘制,android,android-actionbar,Android,Android Actionbar,我在一个形状中有一个两种颜色的渐变,我想把它放在我的应用程序的actionBar中,最好是风格上,因为我希望所有的应用程序栏都有这种视觉效果 我试试这个 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorAccent">@colo

我在一个形状中有一个两种颜色的渐变,我想把它放在我的应用程序的actionBar中,最好是风格上,因为我希望所有的应用程序栏都有这种视觉效果

我试试这个

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
    </style>
    <style name="AppTheme.ActionBar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
        <item name="android:background">@drawable/shape_toolbar</item>
    </style>

@颜色/颜色重音
@style/AppTheme.ActionBar
@可绘制/形状工具栏
但失败了


我该怎么做呢?

你可以切换到
工具栏,而不是标准的
操作栏
,然后对其应用
android:background
样式,几乎和你做的一样


你能自己做这些改变吗?这里有一个很好的指南:

我在这里找到了问题的答案