I needed a simple animation which shows 3-dots loading. So I created 3 images, added it to animation list and set it to imageview. It was working fine till kitkat but after updating my OS to Lollipop, the animation doesn't seem to work.
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="@drawable/one_dot"
android:duration="500"/>
<item
android:drawable="@drawable/two_dot"
android:duration="500"/>
<item
android:drawable="@drawable/three_dot"
android:duration="500"/>
</animation-list>
This is how its set to the imageView
<ImageView
android:id="@+id/dotsLoadingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/loadingText"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:src="@drawable/dots_loading" />
Is there some change regarding animation in Android 5.0 Lollipop?
You have to create a new folder called anim under res directory and make an xml file under anim folder. This method starts the animation. This method sets the duration of an animation.
On Android 4.4 (API level 19) and higher, you can use the transition framework to create animations when you swap the layout within the current activity or fragment. All you need to do is specify the starting and ending layout, and what type of animation you want to use.
The animations are basically of three types as follows: Property Animation. View Animation. Drawable Animation.
You can use the view animation system to perform tweened animation on Views. Tween animation calculates the animation with information such as the start point, end point, size, rotation, and other common aspects of an animation.
From the documentation for AnimationDrawable,
The simplest way to create a frame-by-frame animation is to define the animation in an XML file, placed in the
res/drawable/
folder, and set it as the background to aView
object. Then, callstart()
to run the animation.
You need to call start()
to run the animation.
final ImageView myView = (ImageView) findViewById(R.id.dotsLoadingView);
((Animatable) myView.getDrawable()).start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With