android动画学习之属性动画ObjectAnimator
程序员文章站
2024-03-24 08:28:34
...
ObjectAnimator可以实现多种动画效果,包括透明度,移动,旋转,缩放,并且非常简单
透明度设置:
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, 'alpha', 1.0f, 0.3f, 1.0F);
animator.setDuration(2000);
缩放:
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, 'scaleX', 1.0f, 1.5f);
animator.setDuration(2000).start();
移动:
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, 'translationX', 0.0f, 350.0f, 0f);
animator.setDuration(2500).start();
旋转:
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, 'rotationX', 0.0f, 90.0f,0.0F);
animator.setDuration(2000).start();