Animation List Simply Deosn't Start
I'm working on a project which should have a progressdialog. But since i didn't find an easy way to style a progressdialog, i was thinking, that the easiest way is to create a cust
Solution 1:
Change android:oneshot="true" to android:oneshot="false" so that it repeats. It should be currently only doing one cycle and since your show time is 50, that is really fast. I would also change that to maybe 200 or so..
<?xml version="1.0" encoding="utf-8"?><animation-listxmlns:android="http://schemas.android.com/apk/res/android"android:oneshot="false" ><itemandroid:drawable="@drawable/loadbar_01"android:duration="200" /><itemandroid:drawable="@drawable/loadbar_02"android:duration="200" /><itemandroid:drawable="@drawable/loadbar_03"android:duration="200"/></animation-list>
Also, you are setting the image in your xml layout, but animated the background, so you need to either change the xml layout to this:
<ImageView android:id="@+id/loaddialog_animation" android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/loadanimation"android:layout_marginRight="10dp" />
or change you code to get the src file rather than the background, like this:
image = (ImageView) findViewById(R.id.loaddialog_animation);
image.set(R.drawable.loadanimation);
animation = (AnimationDrawable) image.getDrawable();
Solution 2:
Faced the same issue today. Placing the animation.start()
in the onShow() method of OnShowListener did the trick for me.
publicclassCustomProgressDialogextendsDialog
{
ImageView progressImage;
AnimationDrawable frameAnimation;
publicCustomProgressDialog(Context context)
{
super(context);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.custom_progress);
getWindow().setBackgroundDrawable(newColorDrawable(Color.TRANSPARENT));
progressImage = (ImageView) findViewById(R.id.custom_progress_image);
progressImage.setBackgroundResource(R.anim.progress_anim);
frameAnimation = (AnimationDrawable) progressImage.getBackground();
OnShowListenerosl=newOnShowListener()
{
@OverridepublicvoidonShow(DialogInterface dialog)
{
frameAnimation.start();
}
};
setOnShowListener(osl);
OnDismissListenerodl=newOnDismissListener()
{
@OverridepublicvoidonDismiss(DialogInterface dialog)
{
frameAnimation.stop();
}
};
setOnDismissListener(odl);
}
}
Post a Comment for "Animation List Simply Deosn't Start"