android 动画-Tween Animation(一)动画体系简介,涉及到的核心类、核心接口讲解(上)
来源:互联网 发布:利用js实现动态时间 编辑:程序博客网 时间:2024/06/10 04:14
xml属性
java实现
解释
Animation
android:duration
setDuration(long)
动画持续时间,毫秒为单位
android:fillAfter
setFillAfter(boolean)
控件动画结束时是否保持动画最后的状态
android:fillBefore
setFillBefore(boolean)
控件动画结束时是否还原到开始动画前的状态
android:fillEnabled
setFillEnabled(boolean)
与android:fillBefore效果相同
android:interpolator
setInterpolator(Interpolator)
设定插值器(指定的动画效果,譬如回弹等)
android:repeatCount
setRepeatCount(int)
重复次数
android:repeatMode
setRepeatMode(int)
重复类型有两个值,reverse表示倒序回放,restart表示从头播放
android:startOffset
setStartOffset(long)
调用start函数之后等待开始运行的时间,单位为毫秒
2、AlphaAnimation extends Animation; AlphaAnimation的主要属性都是通过构造函数传递,主要属性如下表:
AlphaAnimation
android:fromAlpha
AlphaAnimation(float fromAlpha, ...)
动画开始的透明度,从0.0 --1.0 ,0.0表示全透明,1.0表示完全不透明
android:toAlpha
AlphaAnimation(..., float toAlpha)
动画结束的透明度,从0.0 --1.0 ,0.0表示全透明,1.0表示完全不透明
3、TranslateAnimation extends Animation,TranslateAnimation中主要的属性都是通过构造函数传递的;
这里简单解释下TranslateAnimation的三个构造函数:
TranslateAnimation(Context context,AttributeSet attrs):这个构造函数是通过xml写View动画的时候系统回调的,我们不用管。
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue,int fromYType, float fromYValue, int toYType, float toYValue)
通过函数的参数我们可以发现XXXType和XXXValue是一一对应的,看字面意思是说,每个Value值可以对应不同Value类型,没错,Value类型不同,ValueType的写法是不一样的;在Animation中给我们提供了三种ValueType,分别是:
public static final int ABSOLUTE = 0;
public static final int RELATIVE_TO_SELF = 1;
通过传入这三种value类型,具体的value的写法也是不一样的,实现效果也是不一样的:
TranslateAnimation(float fromXValue, float toXValue, float fromYValue, float toYValue):这个函数中相对于上一个函数的valueType传值都是ABSOLUTE ,也就是传入的值都必须是绝对的像素值;
TranslateAnimation
android:fromXDelta
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue,
int fromYType, float fromYValue, int toYType, float toYValue)
起始点X轴坐标,可以是数值、百分数、百分数p 三种样式;比如 50、50%、50%p,
android:toXDelta
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue,
int fromYType, float fromYValue, int toYType, float toYValue)
结束点X坐标,可以是数值、百分数、百分数p 三种样式;比如 50、50%、50%p,
android:fromYDelta
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue,
int fromYType, float fromYValue, int toYType, float toYValue)
起始点Y轴从标,可以是数值、百分数、百分数p 三种样式;比如 50、50%、50%p,
android:toYDelta
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue,
int fromYType, float fromYValue, int toYType, float toYValue)
结束点Y轴坐标,可以是数值、百分数、百分数p 三种样式;比如 50、50%、50%p,
ScaleAnimation
android:fromXScale
ScaleAnimation(float fromX, float toX, float fromY, float toY,
float pivotX,float pivotY)
起始的X方向上相对自身的缩放比例,浮点值,比如1.0代表自身无变化,0.5代表起始时缩小一倍,2.0代表放大一倍;
android:toXScale
ScaleAnimation(float fromX, float toX, float fromY, float toY,
float pivotX,float pivotY)
结尾的X方向上相对自身的缩放比例,浮点值;
android:fromYScale
ScaleAnimation(float fromX, float toX, float fromY, float toY,
float pivotX,float pivotY)
起始的Y方向上相对自身的缩放比例,浮点值,
android:toYScale
ScaleAnimation(float fromX, float toX, float fromY, float toY,
float pivotX,float pivotY)
结尾的Y方向上相对自身的缩放比例,浮点值;
android:pivotX
ScaleAnimation(float fromX, float toX, float fromY, float toY,
int pivotXType, float pivotXValue, int pivotYType, float pivotYValue
)
缩放起点X轴坐标,可以是数值、百分数、百分数p三种样式,比如 50、50%、50%p;当为数值时,表示在当前控件的左上角加上50px,做为起始缩放点;如果是50%,表示在当前控件的左上角加上自己宽度的50%做为起始点;如果是50%p,那么就是表示在当前控件的左上角加上父控件宽度的50%做为起始点x轴坐标。
android:pivotY
ScaleAnimation(float fromX, float toX, float fromY, float toY,
int pivotXType, float pivotXValue, int pivotYType, float pivotYValue
)
缩放起点Y轴坐标,取值及意义跟android:pivotX一样。
RotateAnimation
android:fromDegrees
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue,
int pivotYType, float pivotYValue)
开始旋转的角度位置,正值代表顺时针方向度数,负值代码逆时针方向度数
android:toDegrees
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue,
int pivotYType, float pivotYValue)
结束时旋转到的角度位置,正值代表顺时针方向度数,负值代码逆时针方向度数
android:pivotX
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue,
int pivotYType, float pivotYValue)
(pivotXType默认ABSOLUTE)
缩放起点X轴坐标,可以是数值、百分数、百分数p三种样式,比如 50、50%、50%p
android:pivotY
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue,
int pivotYType, float pivotYValue)
(pivotYType默认ABSOLUTE)
缩放起点Y轴坐标,可以是数值、百分数、百分数p三种样式,比如 50、50%、50%p
AnimationSet
<set></set>
AlphaAnimation
<alpha></alpha>
RotateAnimation
<rotate></rotate>
TranslateAnimation
<translate></translate>
ScalceAnimation
<scale></scale>
android:interpolator=""
android:shareInterpolator="">
<scale "通用属性"+“专有属性”/>
<rotate "通用属性"+“专有属性”/>
<alpha "通用属性"+“专有属性”/>
<translate "通用属性"+“专有属性”/>
<set>
<scale/>
...
</set>
</set>
AnimationSet animtionSet = AnimationUtils.loadAnimation(context,R.anim.XXX);//加载xml中的动画布局
由于文章篇幅过长,其他未讲到的内容请看下一节;android 动画-Tween Animation(一)动画体系简介,涉及到的核心类、核心接口讲解(下)
- android 动画-Tween Animation(一)动画体系简介,涉及到的核心类、核心接口讲解(上)
- android 动画-Tween Animation(一)动画体系简介,涉及到的核心类、核心接口讲解(下)
- Android Tween Animation 动画(一)
- Animation动画(一) ---- Tween 场景动画
- Android 动画(一)-View Animation(Tween Animation)
- android 动画-Tween Animation(二) 动画的简单使用
- 核心动画(Core Animation)
- iOSCore Animation(核心动画)
- Android Animation 动画(一)--Tween动画
- Android基础夯实--重温动画(一)之Tween Animation
- iOS 动画讲解(一)之核心动画
- 核心动画(一)
- Android Tween Animation 动画(二)
- 浅谈Android变换动画(Tween Animation)
- Android 渐变动画(Tween animation)
- android补间动画(Tween Animation)
- android Tween动画 (一)
- Android 连续的补间动画(Animation/Tween)
- C++11新特性应用--介绍几个新增的便利算法(用于排序的几个算法)
- Java学习第7天:对象设计模式和懒汉式
- 掰一掰GitHub上优秀的大数据项目
- CSS基础
- I/O接口标准(2):CML、PECL、LVECL和LVDS
- android 动画-Tween Animation(一)动画体系简介,涉及到的核心类、核心接口讲解(上)
- 原型模式与原型链(js学习)
- linux查找被删除但是未释放空间的文件
- 记一次驴唇不对马嘴的DIY之旅(六)
- 如何启动eclipse时提示选择工作空间||删除workspace空间的目录
- LDAP开发
- Linux下修改MySQL的root用户密码
- Mysql简单入门
- python核心编程-线程threading模块二