• 注册
当前位置:1313e > 默认分类 >正文

RotateAnimation 动画旋转

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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://my.oschina.net/u/1181863/blog/478638

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 162202241@qq.com 举报,一经查实,本站将立刻删除。

最新评论

欢迎您发表评论:

请登录之后再进行评论

登录