Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change duration of ripple effect in Android?

I have implemented a ripple effect in android. Using the following code:-

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="#ff00ff00">
    <item android:drawable="@android:color/black" />
</ripple>

And set it to the background of a textview

android:background="@drawable/ripple_over_drawable"

But the problem is that the ripple animation is very fast. I want to slow it down.

like image 789
Rakesh Yadav Avatar asked Nov 08 '22 17:11

Rakesh Yadav


1 Answers

You can achieve the same effect by setting this as a background to the view:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
    android:enterFadeDuration="400"
    android:exitFadeDuration="500">
    <item
        android:state_pressed="true">
        <shape>
            <solid android:color="@color/chrome_grey" />
        </shape>
    </item>
    <item>
        <shape>
            <solid android:color="@android:color/white"/>
        </shape>
    </item>
</selector>
like image 141
Ankit Chandora Avatar answered Nov 14 '22 21:11

Ankit Chandora