您的位置:首页 > 移动开发 > Android开发

android 实现控件的旋转动画效果

2013-07-23 10:11 603 查看
在程序开发中有时候需要让某一个空间旋转一定角度,或者是无限旋转(类似Progressbar)。

其实实现起来也很简单:

RotateAnimation          mFlipAnimation;

mFlipAnimation = new RotateAnimation(0, 45, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
mFlipAnimation.setInterpolator(new LinearInterpolator());
mFlipAnimation.setDuration(80);//如果参数是0,就是无限旋转
mFlipAnimation.setFillAfter(true);


然后就是控件的操作:

your_button.clearAnimation();
your_button.startAnimation(mFlipAnimation);


我实现的效果是你点击的你的button,然后你的button就会旋转45度。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐