How to Create Ripple Effect for Pre-Lollipop

how to create ripple effect for pre-lollipop

You could try this library balysv/material-ripple.

In your gradle, add this line :

compile 'com.balysv:material-ripple:1.0.2'

And this is how to do it :

<com.balysv.materialripple.MaterialRippleLayout
android:id="@+id/ripple"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button inside a ripple"/>
</com.balysv.materialripple.MaterialRippleLayout>

Ripple Effect for pre lollipop

you can use this library by this you can add ripple effect on pre-Lolipop version too.

for example

add button in your layout file

<com.rey.material.widget.Button
style="@style/ButtonRippleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
app:rd_enable="true"/>

add custom style in your style file

<style name="ButtonRippleStyle" parent="Material.Drawable.Ripple.Wave.Light">
<item name="android:background">@null</item>
<item name="rd_rippleColor">#20F15A2B</item>
</style>

Android ripple effect outside view for pre lollipop

Take a look at these 2 libraries:

https://github.com/skyfishjy/android-ripple-background

https://github.com/ruzhan123/RippleView

Sample Image

android ripple effect crashes in pre-lollipop even when I added drawable-21

in drawable-v21 add your rippledrawable and in drawable add the selector drawable , as <ripple> </ripple> tags are used for api >=21



Related Topics



Leave a reply



Submit