I write an android code that has ripple effect by adding:
android:background="?attr/selectableItemBackground"
I need to tweak it. I know how to change the ripple color. But do you think the following are even possible to tune?
- On tap (click and let go), show regular on press color, no ripple.
- When holding the finger longer - show ripple
- Start fade out after 6 milliseconds after the on press
I know adding a drawable selector allows to control more states, but I don't think it can control duration.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="@color/grey200_alpha_10"/>
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="oval">
<solid android:color="@color/grey200_alpha_12"/>
</shape>
</item>
<item android:state_hovered="true">
<shape android:shape="oval">
<solid android:color="@color/grey200_alpha_4"/>
</shape>
</item>
</selector>
Is it possible?
If you wish to proceed with github library then this can help you
https://github.com/traex/RippleEffect
It has a property called
app:rv_rippleDurationwhich lets you control the duration. Also it has many other properties. Must try it outEDIT
Here is a nice answer given by Sunny on StackOverflow
Under the
/platforms/android-14/data/res/themes.xmlyou can find the sources that@android:integer/config_mediumAnimTimeis used for the duration you want to tweak.Now, you can create your own custom drawable file and change the time as per your requirement.