In this post we are gonna see how to create a beautiful ripple animation for your app. You can easily change its color, speed of wave, one ripple or multiple ripples. I have successfully put this in my app. So you may ask any doubts you may have via the comments section below.
Usage
Step 1
Install with Gradle
dependencies {
compile 'com.skyfishjy.ripplebackground:library:1.0.1'
}
Step 2
RippleBackground
Add
RippleBackground
to your layout with content you want, like an ImageView. Configure the view customization elements using styleable attributes.<com.skyfishjy.library.RippleBackground
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content"
app:rb_color="#0099CC"
app:rb_radius="32dp"
app:rb_rippleAmount="4"
app:rb_duration="3000"
app:rb_scale="6">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_centerInParent="true"
android:id="@+id/centerImage"
android:src="@drawable/demoImage"/>
</com.skyfishjy.library.RippleBackground>
Start animation:
final RippleBackground rippleBackground=(RippleBackground)findViewById(R.id.content);
ImageView imageView=(ImageView)findViewById(R.id.centerImage);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
rippleBackground.startRippleAnimation();
}
});
Stop animation:
rippleBackground.stopRippleAnimation();