Android custom selector for ActionBarToggleButton

霸气de小男生 提交于 2019-12-02 04:47:21

In API 21 and more you only need to write this item in style.xml, in your Toolbar theme:

<item name="colorControlHighlight">@color/xxx</item>

But in lower APIs, First you should write this style in your styles.xml:

<style name="MyToolbarTheme.Navigation" parent="@android:style/Widget">
    <item name="android:background">@drawable/selector_items</item>
    <item name="android:scaleType">center</item>
    <item name="android:minWidth">56.0dip</item>
</style>

then add this items to your toolbar theme:

<item name="actionBarItemBackground">@drawable/selector_appbar</item>
<item name="toolbarNavigationButtonStyle">@style/MyToolbarTheme.Navigation</item>

Example:

<style name="MyToolbarTheme" parent="ThemeOverlay.AppCompat.Dark">
    <item name="android:textColorPrimary">#ffffff</item>
    <item name="android:textColorSecondary">#ffffff</item>
    <item name="actionBarItemBackground">@drawable/selector_appbar</item>
    <item name="toolbarNavigationButtonStyle">@style/MyToolbarTheme.Navigation</item>
</style>

(Sorry for my weak English)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!