RotateAnimation类
来源:互联网 发布:太平公主知乎 编辑:程序博客网 时间:2024/06/06 03:42
RotateAnimation类:旋转变化动画类
RotateAnimation类是Android系统中的旋转变化动画类,用于控制View对象的旋转动作,该类继承于Animation类。RotateAnimation类中的很多方法都与Animation类一致,该类中最常用的方法便是RotateAnimation构造方法。
【基本语法】public RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
参数说明
fromDegrees:旋转的开始角度。
toDegrees:旋转的结束角度。
pivotXType:X轴的伸缩模式,可以取值为Animation.ABSOLUTE、Animation.RELATIVE_TO_SELF、Animation.RELATIVE_TO_PARENT。
pivotXValue:X坐标的伸缩值。
pivotYType:Y轴的伸缩模式,可以取值为Animation.ABSOLUTE、Animation.RELATIVE_TO_SELF、Animation.RELATIVE_TO_PARENT。
pivotYValue:Y坐标的伸缩值。
<pre name="code" class="java">public class AccelerometerTest extends Activity{private RotateAnimation rotatAnimation;private Button button1;private Button button2;private ImageView imageView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_myweather_main);//定义动画的旋转角度以及X Y轴的缩放模式及缩放值。rotatAnimation = new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);imageView = (ImageView)findViewById(R.id.imageViewId);//载入图片imageView.setImageDrawable(R.drawable.a_0);button1 = (Button)findViewById(R.id.button1Id);button2 = (Button)findViewById(R.id.button2Id);button1.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {//设置动画持续时间。rotatAnimation.setDuration(3000); //开始动画imageView.startAnimation(rotatAnimation);}});button2.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {//取消动画执行。rotatAnimation.cancel();}});}}
在这段代码中,首先通过RotateAnimation构造方法创建了一个旋转变化的动画对象。然后,在第一个按钮监听器中设置了动画的持续时间,之后启动该动画。在第二个按钮监听器中取消该动画
0 0
- RotateAnimation类
- rotateAnimation
- RotateAnimation
- RotateAnimation
- Android 中的动画 RotateAnimation类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类
- RotateAnimation类:旋转变化动画类,自定义控件通过rotateAnimation实现特效
- RotateAnimation类:旋转变化动画类的使用和总结
- RotateAnimation详解
- RotateAnimation详解
- RotateAnimation动画
- 多态
- c++创建对象的两种方式
- [歪谈]员工(人才),留得住是因为本身就留得住;留不住的,你永远留不住
- TCP 的那些事儿(下)
- 算法java实现--分治法--棋盘覆盖问题
- RotateAnimation类
- LeetCode Combination Sum
- 沪深IF300震荡上行,有短期回落的可能
- position: absolute;绝对定位水平居中问题
- 基于socket的图片传输系统设计
- Scripts:segment_size.sql
- android 自定义进度条颜色
- 无法找到PDB
- 接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)?