动画demo
2016-03-20 11:49
323 查看
补间动画,相对比较简单的动画,但可能会出现灵魂出窍的赶脚,动画移动了,但本身的事件却没有移动
首先在res/anim文件夹下写动画的各种属性
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="6000"
android:fillAfter="true">
</translate>
然后在Java代码中调用
ImageView iv=(ImageView) findViewById(R.id.imageview);
//补间动画
Animation animation=AnimationUtils.loadAnimation(this,R.anim.spalsh_translate);
iv.setAnimation(animation);
animation.start();
帧动画
首先在drawable文件下写各种即将播放的各种图片
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/splash" android:duration="1000"/>
<item android:drawable="@drawable/splash2" android:duration="1000"/>
<item android:drawable="@drawable/splash" android:duration="1000"/>
<item android:drawable="@drawable/splash2" android:duration="1000"/>
<item android:drawable="@drawable/splash" android:duration="1000"/>
<item android:drawable="@drawable/splash2" android:duration="1000"/>
</animation-list>
然后在Java代码中调用
final AnimationDrawable anim = (AnimationDrawable) iv.getBackground();
anim.start(); 属性动画
在animator文件夹下写各种属性
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:propertyName="translationX"
android:valueFrom="0"
android:valueTo="100"
android:valueType="floatType" >
</objectAnimator>在Java代码中调用
Animator anim=AnimatorInflater.loadAnimator(this,R.animator.objectanim);
anim.setTarget(iv);
anim.start();
首先在res/anim文件夹下写动画的各种属性
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="6000"
android:fillAfter="true">
</translate>
然后在Java代码中调用
ImageView iv=(ImageView) findViewById(R.id.imageview);
//补间动画
Animation animation=AnimationUtils.loadAnimation(this,R.anim.spalsh_translate);
iv.setAnimation(animation);
animation.start();
帧动画
首先在drawable文件下写各种即将播放的各种图片
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/splash" android:duration="1000"/>
<item android:drawable="@drawable/splash2" android:duration="1000"/>
<item android:drawable="@drawable/splash" android:duration="1000"/>
<item android:drawable="@drawable/splash2" android:duration="1000"/>
<item android:drawable="@drawable/splash" android:duration="1000"/>
<item android:drawable="@drawable/splash2" android:duration="1000"/>
</animation-list>
然后在Java代码中调用
final AnimationDrawable anim = (AnimationDrawable) iv.getBackground();
anim.start(); 属性动画
在animator文件夹下写各种属性
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:propertyName="translationX"
android:valueFrom="0"
android:valueTo="100"
android:valueType="floatType" >
</objectAnimator>在Java代码中调用
Animator anim=AnimatorInflater.loadAnimator(this,R.animator.objectanim);
anim.setTarget(iv);
anim.start();
相关文章推荐
- Ubuntu 无法访问windows下的磁盘的解决方法
- 并发编程之基础(二)
- iOS 6 7 8 9新特性
- python知识库 Orz
- 系统启动项(/etc/default/grub文件详解)
- Edit Distance [Leetcode解题报告]
- 集合间互相转化
- linux 网络源码布局
- dw子数据窗口dddw自动检索数据
- javaweb——登陆权限过滤器的编写
- 第四周项目4:理解函数的默认参数
- juniper SRX防火墙和cisco 交换机链路聚合配置
- LightOJ 1245 - Harmonic Number (II) (找规律)
- Kafka学习之四 Kafka常用命令
- 批处理教程(1)
- CoreMotion的实际使用,主要获得加速度或者手机朝向
- Java用wait() notify()实现线程间通信
- 辩数字
- 【VB.NET】常用函数概览
- 24.NSURLConnection与RunLoop