简体   繁体   中英

Custom action item background in Android toolbar

I am building android app with app compact theme, as you know api 21 was deprecated actionbar and replace by toolbar . Now i can not custom background of action item on toolbar by drawable selector. Please tell me what is way? This is my code

<android.support.v7.widget.Toolbar
        style="@style/myToolbar"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

<style name="myToolbar">
        <item name="android:minHeight">?attr/actionBarSize</item>
        <item name="android:background">?attr/colorPrimary</item>
        <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
        <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
        <item name="navigationContentDescription">@string/abc_action_bar_up_description</item>

    </style>

Set the "android:actionBarItemBackground" like this:

<item name="android:actionBarItemBackground">@drawable/action_item_ripple</item>

This is set in my values-v21 styles.xml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM