2024年4月25日发(作者:)
IT在线教育平台———麦子学院:
android中提供了如下4种动画效果:
1、AlphaAnimation 透明度动画效果
2、ScaleAnimation 缩放动画效果
3、TranslateAnimation 位移动画效果
4、RotateAnimation 旋转动画效果
今天主要讲解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坐标的伸缩值。
IT在线教育平台———麦子学院:
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) {
te(savedInstanceState);
setContentView(ty_main);
image = (ImageView) findViewById(_img);
start = (Button) findViewById(_start);
IT在线教育平台———麦子学院:
cancel = (Button) findViewById(_cancel);
/** 设置旋转动画 */
final RotateAnimation animation =new
RotateAnimation(0f,360f,VE_TO_SELF,
0.5f,VE_TO_SELF,0.5f);
ation(3000);//设置动画持续时间
/** 常用方法 */
//eatCount(int repeatCount);//设置重复次数
//lAfter(boolean);//动画执行完后是否停留在执行完的状态
//rtOffset(long startOffset);//执行前的等待时间
lickListener(new OnClickListener() {
public void onClick(View arg0) {
mation(animation);
/** 开始动画 */
IT在线教育平台———麦子学院:
ow();
}
});
lickListener(new OnClickListener() {
public void onClick(View v) {
/** 结束动画 */
();
}
});
}
}
更多android视频学习教程,请
看>>/course/2/。
至麦子学院官网查
发布评论