AnimationDrawable
Create bell_animation.xml in the drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true"
>
<item android:drawable="@drawable/bell_01" android:duration="0" />
<item android:drawable="@drawable/bell_02" android:duration="500" />
<item android:drawable="@drawable/bell_03" android:duration="500" />
<item android:drawable="@drawable/bell_01" android:duration="100" />
</animation-list>
where @drawable/bell_01" are the images is the drawable folder
Add this code in the button OnClick handler:
//Home icon in the top bar
button_icon.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable)bell_icon.getDrawable();
//To restart the animation
frameAnimation.setVisible(true, true);
frameAnimation.start();
}
});