Arc*_*nes 4 android android-animation objectanimator
当使用动画时,我可以做这样的事情
ScaleAnimation animation = new ScaleAnimation(0, 1.0, 0, 1.0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
Run Code Online (Sandbox Code Playgroud)
从 0 缩放到对象的原始大小。
我怎样才能对ObjectAnimatoror做同样的事情ValueAnimator?
您可以对ValueAnimator使用类似的东西:
ValueAnimator translate = ValueAnimator.ofFloat(1f, 1.5f);
translate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float scale = Float.parseFloat(animation.getAnimatedValue().toString());
yourView.setScaleX(scale);
yourView.setScaleY(scale);
}
});
translate.start();
Run Code Online (Sandbox Code Playgroud)
对于ObjectAnimator来说是这样的:
AnimatorSet animationSet = new AnimatorSet();
ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 1.5f);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 1.5f);
animationSet.playTogether(scaleX, scaleY);
animationSet.start();
Run Code Online (Sandbox Code Playgroud)
注意:没有测试此代码,有些东西可能无法正常工作。
| 归档时间: |
|
| 查看次数: |
6523 次 |
| 最近记录: |