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?
It's a lot easier to do with styles:
You can control the colour of the
RippleDrawable
by doing the following:Or, via XML:
EDIT
After seeing @i.shadrin's answer below, I must admit it's a much simpler approach (using styles). If this is an option for you, I would recommend it.
If you are using the custom button color then use below code for ripple effect. Save the file in drawable with name my_ripple.xml and set in background of button.
add these two line of code inside of your view to give ripple effect .
An example ripple to use with a selector on api lvl 21 and above