0

I want to create a progress bar which should show moving images effect. for that I have created an animation list and have saved in my drawables folder in res. Here is the code:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/p_one" android:duration="150" />
    <item android:drawable="@drawable/p_two" android:duration="150" />
    <item android:drawable="@drawable/p_three" android:duration="150" />
    <item android:drawable="@drawable/p_threesix" android:duration="150" />

</animation-list>

After that I have used this drawable like this: for my ProressBar Drawable

  <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:indeterminate="true"
        android:indeterminateOnly="true"
        android:indeterminateDrawable="@drawable/progress_bar_anim"
        android:visibility="visible" />

Problem: Nothing is displaying when I run this code. Why ? When I use any single image instead of the animation-list drawable, then it is displayed correctly. Is there any other to do this ?

Gaurav Arora
  • 8,282
  • 21
  • 88
  • 143

2 Answers2

0

Try to add android:oneshot="false" like below in <animation-list ..> attribute

<animation-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
   ...
</animation-list>

android:oneshot="false" is

Boolean. "true" if you want to perform the animation once; "false" to loop the animation.

Android developer link for Frame animation

pRaNaY
  • 24,642
  • 24
  • 96
  • 146
0

Similar strange problems here, I tried two different device, A worked very well, B showed two images in horizontal, I add <clip> in <item> , A became not working, B worked very well, so...better not to use <animation-list> in progressBar...

tysheng
  • 47
  • 7