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/。
至麦子学院官网查
版权声明:本文标题:Android开发ScaleAnimation详解 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1710751292a281655.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论