传统动画Animation的四种基础动画的使用
来源:互联网 发布:ubuntu debian 编辑:程序博客网 时间:2024/05/16 06:47
传统动画: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);
阅读全文
0 0
- 传统动画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旋转的动画
- Hdu2033 人见人爱A+B
- 嵌入式Linux启动过程
- 虚析构函数
- Java值传递和引用传递及形参实参的分析(实例对比c++)
- VIM 的状态行(statusline)设置
- 传统动画Animation的四种基础动画的使用
- 高吞吐量分布式系统kafka
- win10锁屏状态闹钟提示设置
- 墨刀使用总结
- 十,Future设计模式
- c语言基础(三)指针篇
- Git工具安装&项目发布Github
- 剑指offer——二进制中1的个数(好题,原码,反码,补码相关)
- web.xml的一些注意点