Background animation on ProgressBar on Android?

What action should be taken when you need to change the background image of a ProgressBar? I mean, I should use a .gif image, for example: http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif , and if so Does the foreground color of the panel fill the image file during the process? Is there a way to create an animation for the panel background? What I was aiming for was to show the animation for so long that the process did not cover the full bar.

+8
android animation progress-bar
source share
1 answer

you need to get all this gif frame image as an individual, and then set it to an animation list in an XML file.

Here is your anim_progress.xml file code

<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/i1" android:duration="500" /> <item android:drawable="@drawable/i2" android:duration="500" /> <item android:drawable="@drawable/i3" android:duration="500" /> <item android:drawable="@drawable/i4" android:duration="500" /> <item android:drawable="@drawable/i5" android:duration="500" /> <item android:drawable="@drawable/i6" android:duration="500" /> <item android:drawable="@drawable/i7" android:duration="500" /> <item android:drawable="@drawable/i8" android:duration="500" /> </animation-list> 

set the duration of the change as a smooth effect to get an animated image like gif

Here is the code to use this file

 ImageView iv = new ImageView(this); iv.setBackgroundResource(R.drawable.anim_progress); final AnimationDrawable mailAnimation = (AnimationDrawable) iv.getBackground(); iv.post(new Runnable() { public void run() { if ( mailAnimation != null ) mailAnimation.start(); } }); 

setContentView (IV);

You can get all the frames from the gif file from this site.

http://gif-explode.com/

eg

http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif

this link will just pass it and you will get all the images of the frames

+14
source share

All Articles