Android:使用animator收缩动画

Android:使用animator收缩动画,android,animation,android-animation,objectanimator,Android,Animation,Android Animation,Objectanimator,我用以下方式制作动画 有两个布局(都是相对布局),layout1最初将隐藏,layout2最初将向用户显示 一旦动画开始layout1,将使其可见,并且将使用animator缩放layout2,如下所示: Animator scalexAnimator = ObjectAnimator.ofFloat(layout2, "scaleX", 1f, 0f); Animator scaleyAnimator = ObjectAnimator.ofFloat(layout2, "scaleY", 1f

我用以下方式制作动画

有两个布局(都是相对布局),layout1最初将隐藏,layout2最初将向用户显示

一旦动画开始layout1,将使其可见,并且将使用animator缩放layout2,如下所示:

Animator scalexAnimator = ObjectAnimator.ofFloat(layout2, "scaleX", 1f, 0f);
Animator scaleyAnimator = ObjectAnimator.ofFloat(layout2, "scaleY", 1f, 0f);
Animator pivotxAnimator = ObjectAnimator.ofFloat(layout2, "pivotX", <maxWidth>);
Animator pivotyAnimator = ObjectAnimator.ofFloat(layout2, "pivotY", <maxheight/2>);

AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(pivotxAnimator, pivotyAnimator, scalexAnimator, scaleyAnimator);

animatorSet.start();
Animation shrinkAnimation = new ScaleAnimation(1,0.5f,1,05f,Animation.RELATIVE_TO_SELF,1f, Animation.RELATIVE_TO_SELF, 0.5f);

layout2.startAnimation(shrinkAnimation);
这将完美地工作,我将得到一个精确的收缩效果,纵横比保持不变,但我在上面的实现中面临的问题是布局2的位置发生了变化,但按钮保留了它们的位置(layout2有4个按钮,button click在旧的按钮位置工作,即使用户在那里看不到任何按钮,我在一些帖子中读到这是预期的),所以我不得不手动禁用按钮,这是一个开销,所以我想避免使用Animation类,并选择ObjectAnimator

那么ObjectAnimator中有没有办法获得相同的收缩效果呢