我想制作一个Android“繁忙”动画,其图像与默认图像类似。
就像这样:
就像这样:
![enter image description here](https://istack.dev59.com/NFaRR.webp)
ProgressBar
。它提供了一个setIndeterminate()
方法,使其显示一个无限旋转的圆圈(就像你示例中的那个)。setIndeterminateDrawable()
方法。只需使用静态图像并旋转它。这将为您提供所需的效果。
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);
这是帧动画。
您可以查看此文章了解如何创建它:http://yekmer.posterous.com/how-to-make-a-loading-animator-in-android