笔记之android 动画1 用代码来实现动画
2017-02-01 19:59
330 查看
参考自大神博客:
http://blog.csdn.net/harvic880925/article/details/40117115
各个动画标签所对应的类
scale —— ScaleAnimation
alpha —— AlphaAnimation
rotate —— RotateAnimation
translate —— TranslateAnimation
set —— AnimationSet
Amination 是所有动画的基类
android:duration setDuration(long) 动画持续时间,以毫秒为单位
android:fillAfter setFillAfter(boolean)
如果设置为true,控件动画结束时,将保持动画最后时的状态
android:fillBefore setFillBefore(boolean)
如果设置为true,控件动画结束时,还原到开始动画前的状态
android:fillEnabled setFillEnabled(boolean)
与android:fillBefore 效果相同,都是在动画结束时,将控件还原到初始化状态
android:repeatCount setRepeatCount(int)
重复次数
android:repeatMode setRepeatMode(int)
重复类型,有reverse和restart两个值,取值为RESTART或 REVERSE,必须与repeatCount一起使用才能看到效果。因为这里的意义是重复的类型,即回放时的动作。
android:interpolator setInterpolator(Interpolator) 设定插值器,其实就是指定的动作效果,比如弹跳效果等
ScaleAnimation的几个构造函数:
ScaleAnimation(Context context, AttributeSet attrs) 从XML文件加载动画,基本用不到
ScaleAnimation(float fromX, float toX, float fromY, float toY)
ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)
ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
第一个构造方法是以控件左上角为中心进行伸缩
第二个构造方法是以控件的绝对偏移量为中心进行伸缩
第三个构造方法 的pivotXType 有三个类型 Animation.ABSOLUTE、Animation.RELATIVE_TO_SELF和Animation.RELATIVE_TO_PARENT
Animation.ABSOLUTE:绝对值
如50 Animation.RELATIVE_TO_SELF 相对于自身 如 50%
Animation.RELATIVE_TO_PARENT相对于父控件 50%p
AlphaAnimation的几个构造函数:
AlphaAnimation(Context context, AttributeSet attrs) 同样,从本地XML加载动画,基本不用
AlphaAnimation(float fromAlpha, float toAlpha)
RotateAnimation的几个构造函数:
RotateAnimation(Context context, AttributeSet attrs) 从本地XML文档加载动画,同样,基本不用
RotateAnimation(float fromDegrees, float toDegrees)
RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
TranslateAnimation
几个构造函数:
TranslateAnimation(Context context, AttributeSet attrs) 同样,基本不用
TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)
AnimationSet 的构造函数:
AnimationSet(Context context, AttributeSet attrs) 同样,基本不用
AnimationSet(boolean shareInterpolator) shareInterpolator取值true或false,取true时,指在AnimationSet中定义一个插值器(interpolater),它下面的所有动画共同。如果设为false,则表示它下面的动画自己定义各自的插值器。
http://blog.csdn.net/harvic880925/article/details/40117115
各个动画标签所对应的类
scale —— ScaleAnimation
alpha —— AlphaAnimation
rotate —— RotateAnimation
translate —— TranslateAnimation
set —— AnimationSet
Amination 是所有动画的基类
android:duration setDuration(long) 动画持续时间,以毫秒为单位
android:fillAfter setFillAfter(boolean)
如果设置为true,控件动画结束时,将保持动画最后时的状态
android:fillBefore setFillBefore(boolean)
如果设置为true,控件动画结束时,还原到开始动画前的状态
android:fillEnabled setFillEnabled(boolean)
与android:fillBefore 效果相同,都是在动画结束时,将控件还原到初始化状态
android:repeatCount setRepeatCount(int)
重复次数
android:repeatMode setRepeatMode(int)
重复类型,有reverse和restart两个值,取值为RESTART或 REVERSE,必须与repeatCount一起使用才能看到效果。因为这里的意义是重复的类型,即回放时的动作。
android:interpolator setInterpolator(Interpolator) 设定插值器,其实就是指定的动作效果,比如弹跳效果等
ScaleAnimation的几个构造函数:
ScaleAnimation(Context context, AttributeSet attrs) 从XML文件加载动画,基本用不到
ScaleAnimation(float fromX, float toX, float fromY, float toY)
ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)
ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
第一个构造方法是以控件左上角为中心进行伸缩
第二个构造方法是以控件的绝对偏移量为中心进行伸缩
第三个构造方法 的pivotXType 有三个类型 Animation.ABSOLUTE、Animation.RELATIVE_TO_SELF和Animation.RELATIVE_TO_PARENT
Animation.ABSOLUTE:绝对值
如50 Animation.RELATIVE_TO_SELF 相对于自身 如 50%
Animation.RELATIVE_TO_PARENT相对于父控件 50%p
AlphaAnimation的几个构造函数:
AlphaAnimation(Context context, AttributeSet attrs) 同样,从本地XML加载动画,基本不用
AlphaAnimation(float fromAlpha, float toAlpha)
RotateAnimation的几个构造函数:
RotateAnimation(Context context, AttributeSet attrs) 从本地XML文档加载动画,同样,基本不用
RotateAnimation(float fromDegrees, float toDegrees)
RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
rotateAnimation2 = new RotateAnimation(0, 720, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.5f); rotateAnimation2.setDuration(5000);控件使用的时候
tv.startAnimation(rotateAnimation2);
TranslateAnimation
几个构造函数:
TranslateAnimation(Context context, AttributeSet attrs) 同样,基本不用
TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)
AnimationSet 的构造函数:
AnimationSet(Context context, AttributeSet attrs) 同样,基本不用
AnimationSet(boolean shareInterpolator) shareInterpolator取值true或false,取true时,指在AnimationSet中定义一个插值器(interpolater),它下面的所有动画共同。如果设为false,则表示它下面的动画自己定义各自的插值器。
rotateAnimation2 = new RotateAnimation(0, 720, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.5f); rotateAnimation2.setDuration(5000);控件使用的时候
tv.startAnimation(rotateAnimation2);
相关文章推荐
- android基础笔记——补间动画(Tween)代码实现
- Android(java)学习笔记200:Android中View动画之 XML实现 和 代码实现
- Android动画Animation之Tween用代码实现动画效果
- Android动画Animation之Tween用代码实现动画
- 【学习笔记】android动画的不同实现方式以及要点
- 超好看的下拉刷新动画Android代码实现
- Android 摇晃动画代码实现技巧
- android 动画Animation硬代码实现示例
- android动画(3)layout动画,layoutChanged动画及算定义它,ListViewActivity的Layout动画(代码和xm配置两种实现l)
- android开发游记:通过xml配置快速实现点击热点效果和渐变动画(不用java代码)
- Android Animation学习笔记 Posted on 2010-01-11 23:00 feisky 阅读(40227) 评论(12) 编辑 收藏 关于动画的实现,Android提供了A
- android Tween Animations(动画效果-代码实现)的使用
- WebSocket 学习笔记--IE,IOS,Android等设备的兼容性问题与代码实现
- Android(java)学习笔记229:服务(service)之绑定服务调用服务里面的方法 (采用接口隐藏代码内部实现)
- Android(java)学习笔记66:线程的实现方案2思路以及代码实现
- 动画代码Android动画学习笔记动画代码
- WebSocket学习笔记–IE,IOS,Android等设备的兼容性问题与代码实现
- android基础笔记——代码实现挂断电话
- Android中显示GIF动画的实现代码
- Android(java)学习笔记258:JNI之hello.c(c代码功能实现)指针语法解析