Android 动画之RotateAnimation应用详解(旋转动画效果 )(转载)
来源:互联网 发布:如何规划高中知乎 编辑:程序博客网 时间:2024/06/11 05:33
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坐标的伸缩值。
代码:
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();
}
});
}
}
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();
}
});
}
}
0 0
- Android 动画之RotateAnimation应用详解(旋转动画效果 )(转载)
- rotateAnimation 动画效果(转载)
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- Android 动画之RotateAnimation应用详解
- AndroidUI 视图动画-旋转动画效果 (RotateAnimation)
- Android 动画之TranslateAnimation应用详解(位移动画效果 )(转载)
- Android 动画之ScaleAnimation应用详解(缩放动画效果 )(转载)
- Android 动画之AlphaAnimation应用详解(透明度动画效果)转载
- Android动画 之 Tween Animation(RotateAnimation 旋转动画)
- Android动画之RotateAnimation
- Atitit.android jsbridge v1新特性
- [引用区别] c++中引用与java中引用区别
- apt-get update 和 upgrade 的区别
- 对inetd、xinetd与TCP_Wrapper的基本了解
- Struts2 Hello World 实例
- Android 动画之RotateAnimation应用详解(旋转动画效果 )(转载)
- 自定义事件函数Event
- 为什么用dubbo
- NYOJ 106 背包问题
- (OK) 编译cBPM-CentOS7-codeblocks
- TCP/IP协议族
- Android 动画之TranslateAnimation应用详解(位移动画效果 )(转载)
- HDU 2084 数塔
- 【持久化框架】SpringMVC+Spring4+Mybatis3集成,开发简单Web项目+源码下载