I have a linear layout with a couple text boxes, vertical. I want to add/remove one more text box (more specifically, set it to visible/gone). When this happens, I’d like to resize the parent view with an animation rather than just having it jump up and down. I’ve put a layout animation on the parent linear layout, and it animates the box in/out, but it appears to resize first, then animate the child, but that doesn’t really solve the problem I’m having (looks nice, but you know).
Any thoughts?
I know this question is pretty old, but I thought this would be a common problem before I run into it myself.
I took some inspiration from the code you had, but instead of using a separate class like this, what I did is to extend the LinearLayout class and added some methods to be able to animate it when the content changes (in my case, I am making some children views VISIBLE or GONE). Still working out a few details, but it works pretty well so far.
The good thing is that I can access / extend onMeasure method, so I do not have to do any estimation of the size after the animation, no matter what I have in my container, the animation will always go to the right place.
Hope that helps