在我的活动中,我有两张卡片视图,一张用于登录,另一张用于注册。 他们在一堆。当我点击任何一张卡时,它应该像这样动画, https://mir-s3-cdn-cf.behance.net/project_modules/max_1200/82e47d53917017.5971cd622e847.gif
我正在使用Stack动画来实现这一点,但它无法正常工作。 所以任何人都可以帮助我实现这一目标,
stackAnimation.animateStacks(cardViewSignUp, cardViewSignIn, AppConstants.ANIMATION_END_SCALE);
这是我的StackAnimation类,
public class StackAnimation {
private int duration;
private float startScale;
private float pivot;
public StackAnimation(int duration, float startScale, float pivot) {
this.duration = duration;
this.startScale = startScale;
this.pivot = pivot;
}
public void animateStacks(CardView cardViewFront, CardView cardViewBack,
float endScale) {
cardViewBack.bringToFront();
scaleView(cardViewBack, startScale, endScale, startScale, endScale);
scaleView(cardViewFront, startScale, startScale - (endScale - startScale), startScale, startScale - (endScale - startScale));
}
private void scaleView(View view, float startScaleY, float endScaleY, float startScaleX,
float endScaleX) {
Animation anim = new ScaleAnimation(
startScaleX, endScaleX, // Start and end values for the X axis scaling
startScaleY, endScaleY, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_PARENT, pivot, // Pivot point of X scaling
Animation.RELATIVE_TO_PARENT, pivot); // Pivot point of Y scaling
anim.setFillAfter(true); // Needed to keep the result of the animation
anim.setDuration(duration);
view.startAnimation(anim);
}
}