传统动画Animation的四种基础动画的使用
来源:互联网 发布:淘宝售后服务期限 编辑:程序博客网 时间:2024/05/16 08:25
传统动画:animation
Duration:动画持续的时间
第一种:AlphaAnimation(透明度动画)
fromAlpha 动画起始时透明度
toAlpha 动画终止时透明度
0.0 表示完全透明/1.0 表示完全不透明
Xml代码实现:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<alpha
android:duration="1000"
android:fromAlpha="0.1"
android:toAlpha="1.0" >
</alpha>
</set>
第二种:RotateAnimation 旋转动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<rotate
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="+360" />
</set>
第三种:TranslateAnimation 位移动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fromXDelta="10"
android:fromYDelta="10"
android:toXDelta="100"
android:toYDelta="100" />
</set>
第四种:ScaleAnimation缩放动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
android:duration="2000"
android:fillAfter="false"
android:fromXScale="0.0"
android:fromYScale="0.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
动画的调用ImageView控件示例代码:
image = (ImageView) findViewById(R.id.image);
Animation loadAnimation;
loadAnimation = AnimationUtils.loadAnimation(this, R.anim.translate);
image.startAnimation(loadAnimation);
R.anim.translate是对应自己创建的xml代码
特例1:组合动画的示例: android:startOffset="3000"该属性主要是设置动画的开始时间的延迟的长度
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<alpha
android:duration="3000"
android:fromAlpha="0.2"
android:toAlpha="1.0" />
<alpha
android:duration="3000"
android:fromAlpha="1.0"
android:startOffset="3000"
android:toAlpha="0.2" />
</set>
特例2:LayoutAnimation布局动画(以listView为例)
在布局动画控制器中添加一个动画
LayoutAnimationController lac=new LayoutAnimationController (AnimationUtils.loadAniamtion(this,R.anim.zoom_in))
设置加载顺序
lac.setOrder(LayoutAnimationController.ORDER_RANDOM)
ListView加载动画
listView.setLayoutAnimation(lac)
启动动画
listView.startLayoutAnimation()
特例3:FrameAnimation(逐帧动画)
第一步:
使用animation-list标签来分组一个item标签的集合
定义要显示的图片
指定它要显示的时间(以毫秒为单位)
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/one"
android:duration="500"/>
<item
android:drawable="@drawable/two"
android:duration="500"/>
<item
android:drawable="@drawable/three"
android:duration="500"/>
<item
android:drawable="@drawable/four"
android:duration="500"/>
<item
android:drawable="@drawable/five"
android:duration="500"/>
<item
android:drawable="@drawable/six"
android:duration="500"/>
</animation-list>
第二步:在控件中的调用:(以ImageView为例)
image.setImageResource(R.drawable.anim_list);
- 传统动画Animation的四种基础动画的使用
- 传统动画Animation的四种基础动画的使用
- 传统动画Animation的四种基础动画的使用
- Android的animation的四种动画
- Android 动画效果(二):四种基础动画的 **动态设置、动画监听、组合动画
- iOS_Core Animation核心动画 基础动画的学习与总结
- Animation四种动画详解
- Android的四种基础动画
- Android的animation(动画)
- css3的animation 动画
- uiview的animation动画
- animation动画的基础知识
- Animation动画的解析
- css3的动画animation
- Animation动画的解析
- UIView的动画 Animation
- Android的animation动画
- Animation旋转的动画
- libcurl 配合epoll 的异步并行server原理
- 深度学习翻译一
- 关于虚拟机: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled问题解决方案
- 小程序请求API接口,网络请求封装
- LeetCode之7,数论部分的ReverseInteger
- 传统动画Animation的四种基础动画的使用
- Qt编码格式总结
- 消失的步行街:复旦南京路
- u盘制作ubuntu系统盘
- hdu 6012(离散+思路)
- Android性能优化系列—布局优化
- windows下定期自动备份本地文件(文件夹)
- 三层架构和MVC的区别
- 棋盘问题 dfs