帧动画、补间动画、属性动画

帧动画

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="true" > 

    <item 
        android:drawable="@drawable/c1" 
        android:duration="200"/> 

</animation-list>

AnimationDrawable animationDrawable =(AnimationDrawable) imge2.getDrawable();
        animationDrawable.start();

补间动画

在res目录中新建anim文件夹
在anim目录中新建一个my_anim.xml(注意文件名小写)
android:duration=”2000” 动画消耗时间
android:fillAfter=”true” 动画结束后停留在开始帧还结束帧
android:fillBefore=”false”

alph 渐变透明度动画效果
scale 渐变尺寸伸缩动画效果
translate 画面转换位置移动动画效果
rotate 画面转移旋转动画效果

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:fillBefore="false">
    <scale
        android:pivotY="50%"
        android:pivotX="50%"
        android:fromXScale="1"
        android:fromYScale="1"
        android:toXScale="2"
        android:toYScale="2"/>
</set>

 //加载动画文件
        Animation animation1 = AnimationUtils.loadAnimation(this,R.anim.test1);
        Animation animation2 = AnimationUtils.loadAnimation(this,R.anim.test2);
animation1.getRepeatCount()
        AnimationSet set=new AnimationSet(true);
        set.addAnimation(animation1);
        set.addAnimation(animation2);
        //启动动画
        imge.startAnimation(set);

属性动画:

View在3.0之后引入的几个新的属性,并设置了其getter和setter方法:

1)translationX 和 translationY:这两个属性控制了View所处的位置,它们的值是由layout容器设置的,是相对于坐标原点(0,0左上角)的一个偏移量。

2)rotation, rotationX 和 rotationY:控制View绕着轴点(pivotX和pivotY)旋转。

3)scaleX 和 scaleY:控制View基于pivotX和pivotY的缩放。

4)pivotX 和 pivotY:旋转的轴点和缩放的基准点,默认是View的中心点。

5)x 和 y:描述了view在其父容器中的最终位置,是左上角左标和偏移量(translationX,translationY)的和。

6)aplha:透明度,1是完全不透明,0是完全透明。

res/animator/tesst.xml


    <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"

        android:duration="2000"
        android:propertyName="translationX"
        android:valueFrom="0dp"
        android:valueTo="300dp"
        />


    private ImageView imge2;


 ObjectAnimator oa=(ObjectAnimator) AnimatorInflater.loadAnimator(this,R.animator.test);

        oa.setTarget(imge2);

        oa.start();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值