Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ripple background color

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?

like image 749
qwertz Avatar asked May 31 '15 11:05

qwertz


People also ask

What is the default ripple color android?

android:colorControlHighlight will give the ripple the same color as the built-in ripples in your app. If you don't like the default grey, you can specify what color you want android:colorControlHighlight to be in your theme.

What is ripple effect in android?

The touch feedback in Android is a must whenever the user clicks on the item or button ripple effect when clicking on the same, gives confidence to the user that the button has been clicked so that they can wait for the next interaction of the app.

What is RippleDrawable?

android.graphics.drawable.RippleDrawable. Drawable that shows a ripple effect in response to state changes. The anchoring position of the ripple for a given state may be specified by calling setHotspot(float, float) with the corresponding state attribute identifier.


1 Answers

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> 
like image 150
i.shadrin Avatar answered Oct 13 '22 12:10

i.shadrin