Is there any library or dependency to add ripple effect in existing project,I don't want define ripple effect on each views, just want to add effect on one place for whole project.
Asked
Active
Viewed 774 times
0
-
check [this](http://stackoverflow.com/questions/26604134/how-to-achieve-ripple-animation-using-support-library) out – Mehran Zamani Feb 11 '17 at 07:51
-
i don't want to add ripple effect on each button specifically, i just want to add as we are adding theme of the app. – Ashish srivastava Feb 11 '17 at 08:06
-
i know but you can have it in your style or theme as well. the code is added to xml. it is `android:background = ...` – Mehran Zamani Feb 11 '17 at 08:19
-
use styles pattern – Ak9637 Feb 11 '17 at 08:22
1 Answers
0
Ripple effect is for API 21 and above. You can define in app theme as follows:
Without AppCompat
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:colorControlHighlight">@color/your_custom_color</item>
</style>
</resources>
your_custom_color will appear on Button
, ImageButton
, etc.Views
With AppCompat
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlHighlight">@color/your_custom_color</item>
</style>
</resources>
Also, Using ?android:colorControlHighlight
, ?attr/selectableItemBackground
will give the ripple the same color as the built-in ripples in your app for any View
as background
.

Anurag Singh
- 6,140
- 2
- 31
- 47