Android的ImageView的动画动画、Android、ImageView

2023-09-12 22:07:24 作者:、不合格

我已经创建了一个图像视图和网络视图的布局。 Web视图设置为具有走了一个默认的知名度。当活动触发了它显示的图像视图首先,当Web视图已完成加载的URL,它本身标记为可见光和ImageView的标记为隐藏。

I've created a layout with an image view and a web view. The web view is set to have a default visibility of gone. When the activity fires up it displays the image view first and when the web view has finished loading its url, it marks itself as visible and the imageview is marked as hidden.

在ImageView的显示,我想它只是一点点增加潇洒反复旋转。

When the imageview is shown, I would like it to rotate repeatedly just for a little added pizazz.

我从来没有在Android和所有我发现,当我问互联网是没有帮助的帖子做动画;因此,我又回到了SO寻求帮助。

I have never done animations before in Android and all the posts I found when I asked the internet were not helpful; thus, I have returned to SO for help.

所以,如果我开始用这种...

So if I start with this...

    final ImageView splash = (ImageView)findViewById(R.id.splash);

如何创建一个反复旋转动画,并把它应用到ImageView的?

How do I create a repeated rotate animation and apply it to the ImageView?

再次感谢!

推荐答案

使用一个RotateAnimation,设置支点,以图像的中心。

Use a RotateAnimation, setting the pivot point to the centre of your image.

RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(700);

// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.splash);
splash.startAnimation(anim);

// Later.. stop the animation
splash.setAnimation(null);