Android - Having different ripple colors for action bar and action mode with AppCompat

99封情书 提交于 2019-12-06 07:13:49

问题


I wonder if it is possibile to have two different colors for the ripple effect in Action Bar and Action Mode. I've tried a lot of solutions but none worked. I've got this in my style.xml file:

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="colorAccent">@color/holo_blue</item>
    <item name="colorControlHighlight">@color/holo_blue</item>
    <item name="actionModeStyle">@style/ActionModeStyle</item>
</style>

<style name="ActionModeStyle" parent="Widget.AppCompat.ActionMode">
    <item name="background">@drawable/action_mode_style</item>
</style>

And this is the content of the action_mode_style.xml file (v21 version):

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/holo_green">

    <item android:drawable="@color/holo_green_dark" />
</ripple>

My problem is that I can't override the colorControlHighlight attribute for the action mode. So now I've the normal action bar with a blue ripple effect and the action mode bar with a dark green background (correct) but a blue ripple effect instead of a green one because of the colorControlHighlight attribute (in fact, if I comment that attribute, I don't have anymore the blue ripple on the action bar and the green one on the action mode). Is there any chance to having two different ripple effects color for action bar and action mode? Thank you all in advice.

来源:https://stackoverflow.com/questions/29820178/android-having-different-ripple-colors-for-action-bar-and-action-mode-with-app

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