Android中的补间动画(tween)的简单使用
2014-06-24 22:35
453 查看
相对帧动画,补间动画(tween)可以这么理解:我们不必像帧动画一样指定动画的每一帧,只需定义一个动画的开始和结束关键帧,而中间变化的帧由系统帮我们计算。
tween动画可以分为下面几种:
AlphaAnimation(透明渐变动画):
示例:res/anim/alpha.xml
duration:动画持续的时间
fromAlpha:渐变开始值,Float 0.0完全透明 1.0完全不透明
toAlpha:渐变结束值
repeatCount: 动画重复次数
repeatMode:动画重复模式,["repeat"|"reverse"] repeat(透明-不透明 透明-不透明)
reverse(透明-不透明 不透明-透明)
开始动画:
res/anim/scale.xml
fromXScale,fromYScale: 动画开始时缩放比(x,y轴)
toXScale,toYscale: 动画结束时缩放比
pivotX,pivotY:缩放中心点 (50%,50%)则为自身中心点(0,0)左上方
TranslateAnimation(位移动画):
res/anim/translate.xml
toXDelta toYDelta: 结束位置坐标
RotateAnimation(旋转动画):
res/anim/rotate.xml
fromDegrees:旋转开始角度
toDegrees:旋转结束角度,
pivotX pivotY:旋转中心点
上面动画实现以自身中心点为基准点旋转360度
tween动画可以分为下面几种:
AlphaAnimation(透明渐变动画):
示例:res/anim/alpha.xml
<?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000" android:fillAfter="true" android:fromAlpha="0.0" android:repeatCount="1" android:repeatMode="reverse" android:toAlpha="1.0" > </alpha>属性介绍:
duration:动画持续的时间
fromAlpha:渐变开始值,Float 0.0完全透明 1.0完全不透明
toAlpha:渐变结束值
repeatCount: 动画重复次数
repeatMode:动画重复模式,["repeat"|"reverse"] repeat(透明-不透明 透明-不透明)
reverse(透明-不透明 不透明-透明)
开始动画:
Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha); iv.startAnimation(animation); //使用ImageView的startAnimation开始动画ScaleAnimation(缩放动画):
res/anim/scale.xml
<?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000" android:fillAfter="false" android:fromXScale="0.2" android:fromYScale="0.2" android:pivotX="50%" android:pivotY="50%" android:repeatCount="1" android:repeatMode="reverse" android:toXScale="2.0" android:toYScale="2.0" > </scale>主要属性说明:
fromXScale,fromYScale: 动画开始时缩放比(x,y轴)
toXScale,toYscale: 动画结束时缩放比
pivotX,pivotY:缩放中心点 (50%,50%)则为自身中心点(0,0)左上方
TranslateAnimation(位移动画):
res/anim/translate.xml
<?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="-50%p" android:fromYDelta="0.0" android:toXDelta="50%p" android:toYDelta="0.0" android:repeatCount="1" android:repeatMode="reverse" android:duration="2000" > </translate>fromXDelta fromYDelta:开始位置坐标,可以是Float值和百分比 50%p以父容器为参考
toXDelta toYDelta: 结束位置坐标
RotateAnimation(旋转动画):
res/anim/rotate.xml
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:toDegrees="360" android:pivotX="50%" android:pivotY="50%" android:repeatCount="1" android:repeatMode="reverse" android:duration="2000" > </rotate>属性介绍:
fromDegrees:旋转开始角度
toDegrees:旋转结束角度,
pivotX pivotY:旋转中心点
上面动画实现以自身中心点为基准点旋转360度
相关文章推荐
- Android开发之tween(补间动画)动画及其使用场景(界面切换、弹窗等)详解
- Android 补间动画的简单介绍及使用
- Android补间动画(Tween Animation)的使用总结
- 补间动画TweenAnimation-简单使用
- Android之补间动画Tween(set简单的一般够用)
- Android笔记 动画之tween(补间)动画demo
- android游戏开发框架libgdx的使用(二十三)—使用Universal Tween Engine实现动画效果
- Android动画:AnimationDrawable资源的简单使用
- Android——动画之补间动画(Tween动画)
- Android中的帧动画的简单使用
- Tween Animation 补间动画 xml中的简单实现
- 关于 android Tween动画 和 frame动画的简单学习
- Android两大动画之Tween(补间动画)详解
- Android--Tween补间动画
- android基础笔记——补间动画(Tween)代码实现
- Android开发之旅一简单的Animator动画使用
- Android开发(26)--补间动画(Tween)的实现
- android 帧Frame和补间Tween动画
- Android中的动画效果学习之二---Tween动画(使用XML文件进行配置动画效果)
- Android Animation Tween动画效果的使用