How to animate a child view and have a parent view for auto resizing?

I have a quick question.

I try to revive a child view so that it disappears. This part is simple, but during the animation, the parent view does not change. How to make the size of the parent image change automatically during the animation?

Here is my current code:

AnimationSet set = new AnimationSet(true); Animation fade = new ScaleAnimation(1.f, 1.f, 1.f, 0); Animation fade2 = new AlphaAnimation(1, 0); set.addAnimation(fade); set.addAnimation(fade2); set.setDuration(2000); set.setFillAfter(true); bgColor.startAnimation(set); 

bgColor is the kind that I am disappearing. Here is the final result: Result

You can see the space after the animation.

Any ideas?

Thanks in advance!

+4
source share
1 answer

You can add an AnimationListener and make changes to the layout after the animation is complete.

 animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { bgColor.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); 

Also, be sure to report your material regarding onFillAfter ()!

0
source

All Articles