AnimBitmaps
Overview
https://developer.android.com/training/animation
Animate drawable graphics
The first option is to use an Animation Drawable. This allows you to specify several static drawable files that will be displayed one at a time to create an animation. The second option is to use an Animated Vector Drawable, which lets you animate the properties of a vector drawable.
The XML file consists of
<animation=list>
1
2
3
4
5
6<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
</animation-list>in which the animation is added to an
ImageView
and then animated when the screen is touched
1 | private lateinit var rocketAnimation: AnimationDrawable |
It’s important to note that the start()
method called on the AnimationDrawable
cannot be called during the onCreate()
method of your Activity, because the AnimationDrawable
is not yet fully attached to the window. If you want to play the animation immediately, without requiring interaction, then you might want to call it from the onStart()
method in your Activity, which will get called when Android makes the view visible on screen.