0

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.

Charuක
  • 12,953
  • 5
  • 50
  • 88

1 Answers1

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