您的位置:首页 > 其它

动画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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: