动画demo

补间动画,相对比较简单的动画,但可能会出现灵魂出窍的赶脚,动画移动了,但本身的事件却没有移动

首先在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();



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值