Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

animation-list not working in Android 5.0 (Lollipop)

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?

like image 571
Deepak Senapati Avatar asked Mar 16 '15 09:03

Deepak Senapati


People also ask

How do I set up animator on Android?

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.

Is animation possible on Android?

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.

Which animation system is used in Android application?

The animations are basically of three types as follows: Property Animation. View Animation. Drawable Animation.

What is view animation in Android Studio?

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.


1 Answers

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 a View object. Then, call start() 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();
like image 194
alanv Avatar answered Sep 19 '22 17:09

alanv