如何制作默认的Android加载动画?

5
我想制作一个Android“繁忙”动画,其图像与默认图像类似。
就像这样: enter image description here

4
欢迎来到StackOverflow。你实际上没有提出问题。我猜想你的问题是“如何做?”无论如何,在发帖之前请先进行一些调查并尝试自己解决问题。然后发布一个具体的问题,详细说明哪些部分不起作用以及你尝试过哪些方法。包括小代码片段、你的尝试截图和必要程度的描述(通常一句话不够)。谢谢! - user658042
1
http://developer.android.com/reference/android/widget/ProgressBar.html - Selvin
3个回答

4
如果你需要在你的Android应用程序中使用类似于这样的东西,你可以使用一个ProgressBar。它提供了一个setIndeterminate()方法,使其显示一个无限旋转的圆圈(就像你示例中的那个)。
如果需要另一个可绘制对象,你可以使用setIndeterminateDrawable()方法
如果你只想要这个旋转圆圈的动画图像(例如用于Ajax加载过程),你可以在这里找到一个:http://www.ajaxload.info/

1

只需使用静态图像并旋转它。这将为您提供所需的效果。

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

0

1
遗憾的是,posterous.com已经不再运营。现在我们程序员要承担这个代价了。 - Reactgular

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接