android中提供了4中动画:
AlphaAnimation 透明度动画效果
ScaleAnimation 缩放动画效果
TranslateAnimation 位移动画效果
RotateAnimation 旋转动画效果 本节解说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();
}
});
}
}
本节解说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();
}
});
}
}
 
本节解说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坐标的伸缩值。
代码:
复制代码 代码例如以下:
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();
}
});
}
}
本节解说TranslateAnimation动画,TranslateAnimation比較经常使用,比方QQ,网易新闻菜单栏的动画,就能够用TranslateAnimation实现,
通过TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) 来定义动画 參数说明:
复制代码 代码例如以下:
float fromXDelta 动画開始的点离当前View X坐标上的差值
float toXDelta 动画结束的点离当前View X坐标上的差值
float fromYDelta 动画開始的点离当前View Y坐标上的差值
float toYDelta 动画開始的点离当前View Y坐标上的差值
经常用法:
复制代码 代码例如以下:
animation.setDuration(long durationMillis);//设置动画持续时间
animation.setRepeatCount(int i);//设置反复次数
animation.setRepeatMode(Animation.REVERSE);//设置反方向运行
Xml属性:
复制代码 代码例如以下:
android:duration:执行动画的时间
android:repeatCount:定义动画反复的时间
代码:
复制代码 代码例如以下:
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);
/** 设置位移动画 向右位移150 */
final TranslateAnimation animation = new TranslateAnimation(0, 150,0, 0);
animation.setDuration(2000);//设置动画持续时间
animation.setRepeatCount(2);//设置反复次数
animation.setRepeatMode(Animation.REVERSE);//设置反方向运行
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();
}
});
}
}
 
 
 
 
本节解说AlphaAnimation 动画,窗体的动画效果,淡入淡出什么的,有些游戏的欢迎动画,logo的淡入淡出效果就使用AlphaAnimation。
直接看代码:
复制代码 代码例如以下:
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 AlphaAnimation animation = new AlphaAnimation(1, 0);
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();
}
});
}
}
 
 
 
 
 
 
 
 
 
 


Android 动画之ScaleAnimation应用具体解释的更多相关文章

  1. Android 动画之ScaleAnimation应用详解

    本节讲解ScaleAnimation 动画, ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, ...

  2. android动画具体解释一 概述

    动画和图形概述 Android 提供了大量的强大的API以应用于UI动画和绘制2D和3D图形.以下各节向你描写叙述了这些API的预览和系统能力以帮助你决定怎么才是达到你需求的最佳方法. 动画 Andr ...

  3. android动画具体解释二 属性动画原理

    property动画是一个强大的框架,它差点儿能使你动画不论什么东西. 你能够定义一个动画来改变对象的不论什么属性,不论其是否被绘制于屏幕之上. 一个属性动画在一定时间内多次改变一个属性(对象的一个字 ...

  4. android动画具体解释六 XML中定义动画

    动画View 属性动画系统同意动画View对象并提供非常多比view动画系统更高级的功能.view动画系统通过改变绘制方式来变换View对象,view动画是被view的容器所处理的,由于View本身没 ...

  5. android动画具体解释四 创建动画

    使用ValueAnimator进行动画 通过指定一些int, float或color等类型的值的集合.ValueAnimator 使你能够对这些类型的值进行动画.你需通过调用ValueAnimator ...

  6. android 动画xml属性具体解释

    /** * 作者:crazyandcoder * 联系: * QQ : 275137657 * email: lijiwork@sina.com * 转载请注明出处! */ android 动画属性具 ...

  7. Android动画学习笔记-Android Animation

    Android动画学习笔记-Android Animation   3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中 ...

  8. 【Android动画】之Tween动画 (渐变、缩放、位移、旋转)

    Android 平台提供了两类动画. 一类是Tween动画,就是对场景里的对象不断的进行图像变化来产生动画效果(旋转.平移.放缩和渐变). 第二类就是 Frame动画,即顺序的播放事先做好的图像,与g ...

  9. Android 动画深入分析

    一些娱乐动画安德鲁斯被广泛使用应用上述的.在不牺牲性能,它可以带来非常好的体验,下面会解释具体的实现安卓动画.知识的学校一个明确清晰的白色. 动画类型 Android的animation由四种类型组成 ...

随机推荐

  1. 安装vs2015的时候出现的各种 1402错误

    经搜索与尝试,确认为注册表权限问题,改过好几个子项,均提示不能修改设置子项的所有者什么的,后来一怒之下,直接把install节点下的compom项的权限的administratos权限删掉,删除的时候 ...

  2. Kyoya and Colored Balls(组合数)

    Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  3. NTP-ntpdate:no server suitable for synchronization found

    NTP-ntpdate 问题处理 解决ntp的错误 no server suitable for synchronization found 当用ntpdate -d 来查询时会发现导致 no ser ...

  4. 【set&&sstream||floyed判环算法】【UVa 11549】Calculator Conundrum

    CALCULATOR CONUNDRUM Alice got a hold of an old calculator that can display n digits. She was bored ...

  5. php错误日志级别

    ; E_ALL             所有错误和警告(除E_STRICT外) ; E_ERROR           致命的错误.脚本的执行被暂停. ; E_RECOVERABLE_ERROR   ...

  6. php.ini中最好禁止的一些函数

    phpinfo() 功能描述:输出 PHP 环境信息以及相关的模块.WEB 环境等信息. 危险等级:中 passthru() 功能描述:允许执行一个外部程序并回显输出,类似于 exec(). 危险等级 ...

  7. 2台linux机器免密码互相登陆

    一,如何使2台机器不需要密码互相登陆到对方呢? 这个和使用密钥的登陆Linux系统非常相似,也是将自己的公钥传到要登录的服务器上去修改权限即可. 1,A机器: 执行ssh-keygen命令,一路回车. ...

  8. Springmvc和velocity使用的公用后台分页

    Springmvc和velocity使用的公用后台分页 类别                    [选择一个类别或键入一个新类别] Springmvc和velocity使用的公用后台分页 样式: 使 ...

  9. 解决升级Xcode后插件不能使用的问题

    从Xcode 5开始,苹果要求加入UUID证书从而保证插件的稳定性.因此Xcode版本更新之后需要在插件的Info.plist文件中添加当前Xcode的UUID. 具体步骤如下: 1.获取Xcode的 ...

  10. Spring-----8、深入理解容器中的bean

    转载自:http://blog.csdn.net/hekewangzi/article/details/45648687