admin管理员组

文章数量:1536086

2024年3月18日发(作者:)

IT在线教育平台———麦子学院:

android中提供了如下4种动画效果:

1、AlphaAnimation 透明度动画效果

2、ScaleAnimation 缩放动画效果

3、TranslateAnimation 位移动画效果

4、RotateAnimation 旋转动画效果

今天主要讲解ScaleAnimation 缩放动画效果的实现方法。

ScaleAnimation参数有:float fromX, float toX, float

pivotXType, float pivotXValue, int pivotYType, float pivotYValue

分别是:

float fromX 动画起始时 X坐标上的伸缩尺寸

float toX 动画结束时 X坐标上的伸缩尺寸

float fromY 动画起始时Y坐标上的伸缩尺寸

float toY 动画结束时Y坐标上的伸缩尺寸

int pivotXType 动画在X轴相对于物件位置类型

fromY, float toY,int

IT在线教育平台———麦子学院:

float pivotXValue 动画相对于物件的X坐标的开始位置

int pivotYType 动画在Y轴相对于物件位置类型

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);

IT在线教育平台———麦子学院:

start = (Button) findViewById(_start);

cancel = (Button) findViewById(_cancel);

/** 设置缩放动画 */

final ScaleAnimation animation =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f,

VE_TO_SELF, 0.5f, VE_TO_SELF, 0.5f);

ation(2000);//设置动画持续时间

/** 常用方法 */

//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/。

至麦子学院官网查

本文标签: 动画坐标效果执行缩放