0
votes

I have an activity like below screen.

Activity1

View 1 have width and height as match_parent respectively. View 2 have width match_parent and fixed (200 dp) height.

On a button click I change the visibility (from visible to gone) of View 2. As soon as I hide View 2, View 1 comes in full screen instantly or with a jerk. I want the View 1 to gradually expand to full screen with animation instead of instantly.

How can I animate this layout size change?

2

2 Answers

2
votes

You can set android:animateLayoutChanges="true" on the parent layout. This works from API 11 and onward.

0
votes

You need to use scale animation for view1 and fade out for view2 and then use Animatorset to run both at the same time. For example for a simple scale animation

ScaleAnimation anim = new ScaleAnimation(fXscale, toXscale,    fYscale, tYscale, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5);//fix to fit your needs.