I want to make an Android "busy" animation, with similar image to default.
Like this:
If you need something like this in your Android application, you can use a ProgressBar
. It offers a setIndeterminate()
-method which makes it display an infinite spinning circle (like the one in your example).
If another drawable is needed, you can use the setIndeterminateDrawable()
-method.
If you just want an animated image of this spinning circle (e.g. for your Ajax loading-process), you can find one here: http://www.ajaxload.info/
Just use a static image and rotate it. This will give you the desired effect.
ImageView image = (ImageView) findViewById(R.id.refreshicon);
float ROTATE_FROM = 0.0f; // from what position you want to rotate it
float ROTATE_TO = 10.0f * 360.0f; // how many times you want it to rotate in one 'animation' (in this example you want to fully rotate -360 degrees- it 10 times)
RotateAnimation r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
r.setDuration(7500); // here you determine how fast you want the image to rotate
r.setRepeatCount(Animation.INFINITE); // how many times you want to repeat the animation
r.setInterpolator(new LinearInterpolator()); // the curve of the animation; use LinearInterpolator to keep a consistent speed all the way
image.startAnimation(r);
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