如何制作默认的Android loader动画?

如何制作默认的Android loader动画?,android,android-layout,animation,loading,Android,Android Layout,Animation,Loading,我想制作一个Android“忙碌”动画,与默认图像类似 像这样: 只需使用静态图像并旋转它即可。这会给你想要的效果 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 wan

我想制作一个Android“忙碌”动画,与默认图像类似

像这样:


只需使用静态图像并旋转它即可。这会给你想要的效果

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);

如果在Android应用程序中需要类似的东西,可以使用
ProgressBar
。它提供了一个使其显示无限旋转的圆(如您的示例中的圆)

如果需要另一个可拉伸的,可以使用

如果您只需要此旋转圆的动画图像(例如用于Ajax加载过程),可以在此处找到:

它是FrameAnimation


您可以查看本文以了解如何创建它:

欢迎使用StackOverflow。你实际上没有问任何问题。我想那是“怎么做?”?。无论如何,请做一点调查,并试图解决一个问题之前,你自己在这里张贴。然后发布一个具体的问题,详细说明什么不起作用以及你尝试了什么。根据需要,包括小代码片段、您尝试的屏幕截图和适当长度的描述(一句话通常不够)。谢谢哦,天哪,那正是我需要的!非常感谢。所以,你应该接受答案。Saidly posterous.com已不再营业。现在我们程序员要承担成本。