Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After using an animation on a CardView, it then floats over the actionbar. #8

Open
EugeneHoran opened this issue Feb 2, 2015 · 2 comments

Comments

@EugeneHoran
Copy link

I posted the implementation and images showing the issue. I think the images show the issue better than I can explain it. It is probably something on my part but cant seem to fix it.

private boolean isFinished = false;
card2 = (CardView) findViewById(R.id.card2);
editName.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        //TODO     swipeLayout.open();
        card2.setVisibility(View.VISIBLE);
        new FlipVerticalToAnimation(card1).setFlipToView(card2)
                .setInterpolator(new LinearInterpolator()).animate();
        isFinished = true;
    }
});

This is the card before the animation.

screenshot_2015-02-02-12-32-15

This is the card after the animation.

screenshot_2015-02-02-12-32-25

@bennychou
Copy link

I have the same issue. Plz help us.

@bennychou
Copy link

I have find the reason of this issue which is this function "setClipChildren". You have to set "true" after the animation finished, because all views have set "false" before animation started. I could used PuffInAnimation as a example. Please check the following source code of PuffInAnimation.

@OverRide
public void animate() {
final ViewGroup parentView = (ViewGroup) view.getParent();
final ViewGroup rootView = (ViewGroup) view.getRootView();
setClipChildren(rootView, parentView, false);

view.setScaleX(4f);
view.setScaleY(4f);
view.setAlpha(0f);
view.animate().scaleX(1f).scaleY(1f).alpha(1f)
            .setInterpolator(interpolator).setDuration(duration)
            .setListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationStart(Animator animation) {
                    view.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    setClipChildren(rootView, parentView, true);
                    if (getListener() != null) {
                        getListener().onAnimationEnd(PuffInAnimation.this);
                    }
                }
              });

}

private void setClipChildren(ViewGroup rootView, ViewGroup parentView, boolean isClipChildren) {
while (parentView != rootView) {
parentView.setClipChildren(isClipChildren);
parentView = (ViewGroup) parentView.getParent();
}
rootView.setClipChildren(isClipChildren);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants