Android ImageView 动画 [英] Android ImageView Animation

查看:34
本文介绍了Android ImageView 动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有图像视图和网络视图的布局.Web 视图的默认可见性设置为消失.当 Activity 启动时,它首先显示图像视图,当 Web 视图完成加载其 url 时,它将自己标记为可见,而图像视图被标记为隐藏.

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.

当显示图像视图时,我希望它重复旋转只是为了增加一点点活力.

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

这篇关于Android ImageView 动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆