I'm trying to show a ripple animation in imageView before loading the image from the server.
I tried below code:
ImageView imageView = findViewById(R.id.image_view);
// Create a RippleDrawable with a solid color background and no foreground
RippleDrawable rippleDrawable = new RippleDrawable(
ColorStateList.valueOf(Color.BLACK), // Ripple color
null, // Background drawable
null // Foreground drawable
);
// Create an AnimationDrawable that wraps the RippleDrawable
AnimationDrawable animationDrawable = new AnimationDrawable();
animationDrawable.addFrame(rippleDrawable, 1000); // Add the RippleDrawable, with a duration of 1000 ms
animationDrawable.setOneShot(false); // Set the animation to loop indefinitely
// Set the AnimationDrawable as the background of the ImageView
imageView.setBackground(animationDrawable);
// Start the animation
animationDrawable.start();
<ImageView
android:id="@+id/image_view"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
This is not working