android Animation 动画效果介绍 续

来源:互联网 发布:弯沉计算软件 编辑:程序博客网 时间:2024/06/05 09:31
Android动画解析--JavaCode
AlphaAnimation
① AlphaAnimation类对象定义
private AlphaAnimation myAnimation_Alpha;

② AlphaAnimation类对象构造
AlphaAnimation(float fromAlpha, float toAlpha) //第一个参数fromAlpha为 动画开始时候透明度//第二个参数toAlpha为 动画结束时候透明度myAnimation_Alpha=new AlphaAnimation(0.1f, 1.0f);//说明: // 0.0表示完全透明// 1.0表示完全不透明

③ 设置动画持续时间
myAnimation_Alpha.setDuration(5000);//设置时间持续时间为 5000毫秒

ScaleAnimation
① ScaleAnimation类对象定义
private AlphaAnimation myAnimation_Alpha;

② ScaleAnimation类对象构造
ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) //第一个参数fromX为动画起始时 X坐标上的伸缩尺寸 //第二个参数toX为动画结束时 X坐标上的伸缩尺寸 //第三个参数fromY为动画起始时Y坐标上的伸缩尺寸 //第四个参数toY为动画结束时Y坐标上的伸缩尺寸 /*说明:以上四种属性值 0.0表示收缩到没有 1.0表示正常无伸缩 值小于1.0表示收缩 值大于1.0表示放大*///第五个参数pivotXType为动画在X轴相对于物件位置类型 //第六个参数pivotXValue为动画相对于物件的X坐标的开始位置//第七个参数pivotXType为动画在Y轴相对于物件位置类型 //第八个参数pivotYValue为动画相对于物件的Y坐标的开始位置myAnimation_Scale =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
③ 设置动画持续时间
myAnimation_Scale.setDuration(700);//设置时间持续时间为 700毫秒

TranslateAnimation
① TranslateAnimation类对象定义
private AlphaAnimation myAnimation_Alpha;

② TranslateAnimation类对象构造
TranslateAnimation(float fromXDelta, float toXDelta,float fromYDelta, float toYDelta) //第一个参数fromXDelta为动画起始时 X坐标上的移动位置 //第二个参数toXDelta为动画结束时 X坐标上的移动位置 //第三个参数fromYDelta为动画起始时Y坐标上的移动位置 //第四个参数toYDelta为动画结束时Y坐标上的移动位置 

③ 设置动画持续时间
myAnimation_Translate.setDuration(2000);//设置时间持续时间为 2000毫秒

RotateAnimation
① RotateAnimation类对象定义
private AlphaAnimation myAnimation_Alpha;

② RotateAnimation类对象构造
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)//第一个参数fromDegrees为动画起始时的旋转角度 //第二个参数toDegrees为动画旋转到的角度 //第三个参数pivotXType为动画在X轴相对于物件位置类型 //第四个参数pivotXValue为动画相对于物件的X坐标的开始位置//第五个参数pivotXType为动画在Y轴相对于物件位置类型 //第六个参数pivotYValue为动画相对于物件的Y坐标的开始位置myAnimation_Rotate=new RotateAnimation(0.0f, +350.0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF, 0.5f);

③ 设置动画持续时间
myAnimation_Rotate.setDuration(3000);//设置时间持续时间为 3000毫秒

如何使用Java代码中的动画效果
使用从View父类继承过来的方法startAnimation()来为View或是子类View等等添加一个动画效果
public void startAnimation (Animation animation)