Android 动画之RotateAnimation应用详解

近期要写的一个界面中包含一个旋转的动画。 所以就去网上找了下资料,

原文出处:http://www.jb51.net/article/32341.htm

 

本节讲解RotateAnimation 动画, RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) 参数说明:
float fromDegrees:旋转的开始角度。 float toDegrees:旋转的结束角度。 int pivotXType:X轴的伸缩模式,可以取值为ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。 float pivotXValue:X坐标的伸缩值。 int pivotYType:Y轴的伸缩模式,可以取值为ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。 float pivotYValue:Y坐标的伸缩值。 代码:

复制代码 代码如下:
public class MainActivity extends Activity { ImageView image; Button start; Button cancel; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); image = (ImageView) findViewById(R.id.main_img); start = (Button) findViewById(R.id.main_start);
cancel = (Button) findViewById(R.id.main_cancel); /** 设置旋转动画 */
final RotateAnimation animation =new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,
0.5f,Animation.RELATIVE_TO_SELF,0.5f);
animation.setDuration(3000);//设置动画持续时间 /** 常用方法 */
//animation.setRepeatCount(int repeatCount);//设置重复次数
//animation.setFillAfter(boolean);//动画执行完后是否停留在执行完的状态
//animation.setStartOffset(long startOffset);//执行前的等待时间
start.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { image.setAnimation(animation); /** 开始动画 */
animation.startNow(); } }); cancel.setOnClickListener(new OnClickListener() { public void onClick(View v) { /** 结束动画 */
animation.cancel(); } }); } }

效果:  

转载于:https://www.cnblogs.com/dasb/p/4672010.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值