美文网首页
Android-PropertyAnimotion-Object

Android-PropertyAnimotion-Object

作者: wildeyess | 来源:发表于2018-06-05 19:24 被阅读0次

ObjectAnimator(属性动画之objectAnimator)


1.类(ValueAnimator的子类提供了对目标对象的动画属性的支持。此类的构造方法采用参数,来定义要进行动画处理的目标对象或属性名称。然后在内部确定适当的set/get方法, 动画将根据需要调用这些方法,来对进行动画处理这些属性。)

my see:在valueAnimator基础上封装的可以直接将值的变化与view的get,set操作结合的直接处理的类。

2.类方法

  • ofArgb(object target,String propertyName,int...values):构造并返回在指定颜色值之间动画的一个ObjectAnimator的对象。
  • ofFolat(object target,String xPropertyName,String yPropertyName,int...values):构造并返回一个ObjectAnimator对象,其使用两个属性,沿着一个Path坐标进行动画。
  • ofInt(object target,String propertyName,int...values):构造并返回在指定整型值之间动画的一个ObjectAnimator的对象。
  • ofMuiltFloat(object target,String propertyName,int...values):构造并返回一个ObjectAnimator对象, 它使用一个多浮点setter设置的Path,对目标进行动画。
  • ofMuiltInt(object target,String propertyName,int...values):Constructs and returns an ObjectAnimator that animates the target using a multi-int setter along the given Path.
    构造并返回一个ObjectAnimator对象, 它使用一个多整型setter设置的Path,对目标进行动画。
  • ofObject(object target,String propertyName,int...values):构造并返回一个ObjectAnimator对象,它沿着一个Path动画处理一个属性。

3.示例代码(透明度变化,旋转角度,平移位置,缩放大小)

    final Button textView = findViewById(R.id.text_animotion);
    float translationX = textView.getTranslationX();
    final ObjectAnimator animator = ObjectAnimator.ofFloat(textView, "alpha", 0, 1);
    animator.setDuration(5000);
    animator.start();
    final ObjectAnimator xzanimator = ObjectAnimator.ofFloat(textView, "rotation", 0f, 360f, 180f);
    xzanimator.setDuration(5000);
    xzanimator.start();
    final ObjectAnimator pyanimator = ObjectAnimator.ofFloat(textView, "translationX", translationX, 400, translationX);
    pyanimator.setDuration(5000);
    pyanimator.start();
    final ObjectAnimator sfanimator = ObjectAnimator.ofFloat(textView, "scaleX", 1f, 2f, 3f);
    sfanimator.setDuration(5000);
    sfanimator.start();

4.效果图

动画图

相关文章

网友评论

      本文标题:Android-PropertyAnimotion-Object

      本文链接:https://www.haomeiwen.com/subject/qrrmsftx.html