现在的位置: 首页 > 综合 > 正文

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

2013年10月12日 ⁄ 综合 ⁄ 共 460字 ⁄ 字号 评论关闭

在程序开发中有时候需要让某一个空间旋转一定角度,或者是无限旋转(类似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度。

抱歉!评论已关闭.