简单动画

在Android3.0之前,andorid提供了几种动画类型 ViewAnimation,Drawable Animation,Property Ainmation,

 

View Animation相当简单,不过只能支持简单的缩放,平移,旋转,透明度这些基本的动画

 

Google在Android3.0之后,提供了属性动画,这使得动画系统变得极其强大了起来,考虑到很多app需要兼容3.0一下设备,特提供了一个动画库,Nineoldanimations

 

 

属性动画的基本使用:

 

1.      使一个控件在一定的时间里改变其背景颜色并且能够反复循环和反转的效果

 TextView text=(TextView)findViewById(R.id.text);

      ValueAnimatoranimator= ObjectAnimator.ofInt(text,"backgroundColor",0xffff8080,0xff8080ff);

      animator.setDuration(3000);

      animator.setEvaluator(new ArgbEvaluator());

      animator.setRepeatCount(ValueAnimator.INFINITE);

      animator.setRepeatMode(ValueAnimator.REVERSE);

   animator.start();

2.    动画集合,5秒时间内,对view进行旋转,平移,缩放和透明度进行改变

 AnimatorSet set = new AnimatorSet();

    set.playTogether(ObjectAnimator.ofFloat(text, "rotationX",0,360)

         ,ObjectAnimator.ofFloat(text, "rotatioY",0,180)

         ,ObjectAnimator.ofFloat(text, "rotatio",0,-90)

         ,ObjectAnimator.ofFloat(text, "translationX",0,90)

         ,ObjectAnimator.ofFloat(text, "translationY",0,90)

         ,ObjectAnimator.ofFloat(text, "scaleX",1,1.5f)

         ,ObjectAnimator.ofFloat(text, "scaleY",1,0.5f)

         ,ObjectAnimator.ofFloat(text, "alpha",1,0.25f,1)

         );

  set.setDuration(5*1000).start();

 

在使用时需要注意前面的String类型的名字,需要正确,否则没有效果,这里只列举两种情况!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

nibinusm22b

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值