博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android 动画之ScaleAnimation应用详解
阅读量:4553 次
发布时间:2019-06-08

本文共 1482 字,大约阅读时间需要 4 分钟。

本节讲解ScaleAnimation 动画,

ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
参数说明: 

 

float fromX 动画起始时 X坐标上的伸缩尺寸
float toX 动画结束时 X坐标上的伸缩尺寸
float fromY 动画起始时Y坐标上的伸缩尺寸
float toY 动画结束时Y坐标上的伸缩尺寸
int pivotXType 动画在X轴相对于物件位置类型
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) { 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 ScaleAnimation animation =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(2000);//设置动画持续时间 /** 常用方法 */ //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(); } }); } }

 

转载于:https://www.cnblogs.com/AceIsSunshineRain/p/5188974.html

你可能感兴趣的文章
Docker之环境
查看>>
PHP FCKeditor使用小结
查看>>
模拟,搜索,暴力练习
查看>>
Latex 表格(跨行、跨列、背景加灰)new
查看>>
转!!java反射机制
查看>>
三元表达式类型提升
查看>>
原!!mybatis如何直接 执行传入的任意sql语句 并按照顺序取出查询的结果集
查看>>
uva 10603 倒水问题
查看>>
01背包初始化的理解
查看>>
zabbix-agent passive
查看>>
面向对象程序设计(高级)
查看>>
jQuery图片幻灯片插件mobilyslider的使用
查看>>
递归方程组解的渐进阶的求法——套用公式法
查看>>
晨星谈基金· 什么是指数基金
查看>>
Dubbo学习笔记
查看>>
iOS 后台播放音频文件
查看>>
团队第一次合作
查看>>
openoffice启动和自动启动设置(centos)
查看>>
M2团队组员得分分配
查看>>
jvm
查看>>