Android-PropertyAnimotion-Object

2018-06-05  本文已影响0人  wildeyess

ObjectAnimator(属性动画之objectAnimator)


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

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

2.类方法

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.效果图

动画图
上一篇 下一篇

猜你喜欢

热点阅读