Android ripple background color

qwertz picture qwertz · May 31, 2015 · Viewed 31.4k times · Source

I am using a ripple effect on my navigation drawer. I have set it like this and applied it to my ListView:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_activated="true" android:drawable="@color/black_200" />

    <item android:state_pressed="true" android:color="@color/black_200">
        <ripple android:color="@color/black_400" />
    </item>

    <item android:drawable="@color/white" />
</selector>

I want the ripple background to remain the same like the normal activated state. Even when I define the color to be the same as the activated state, it gets darker and the ripple bubble gets even more dark. How can I color the background to be the same like the activated state and the ripple bubble to be the color I told it to be?

Answer

i.shadrin picture i.shadrin · Aug 10, 2015

It's a lot easier to do with styles:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
   ...
   <item name="colorControlHighlight">@color/ripple_material_dark</item>
   ...
</style>