Thanks for your reply. However, the problem I am encountering is the required call to requestLayout(). Even when my view hierarchy is not complex, calling requestLayout() every time the animation needs to update causes many frames to drop and look very choppy. I am hoping to find a way to partially measure the view hierarchy.
On Thursday, June 19, 2014 1:34:06 AM UTC-7, Paul-Peter Tournaris wrote: > > > https://stackoverflow.com/questions/4946295/android-expand-collapse-animation > > > > > On Thu, Jun 19, 2014 at 11:07 AM, Sheng-Dean <[email protected] > <javascript:>> wrote: > >> Hello, >> >> I would like to animate the height of a View to make it look like it is >> expanding. >> >> My current implementation involves a custom Animation class that invokes >> getLayoutParams() and changes the height variable in the >> applyTransformation() method. It looks like this: >> >> @Override >> protected void applyTransformation(float interpolatedTime, >> Transformation t) { >> super.applyTransformation(interpolatedTime, t); >> >> LayoutParams layout = mActor.getLayoutParams(); >> >> int newHeight = fromHeight + (int) ((toHeight-fromHeight) * >> interpolatedTime); >> layout.height = newHeight; >> >> mActor.requestLayout(); >> } >> >> However, animations are choppy because whenever I invoke requestLayout(), >> it layouts the entire view hierarchy, which is expensive, resulting in >> choppy animations (eg 10fps). I have tried forceLayout(), hoping that it >> would only layout a portion of the view hierarchy, however it seems to do >> nothing... >> >> Please give me some advice on how I can implement this sort of animations >> correctly. >> >> Thank you. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> <javascript:> >> To unsubscribe from this group, send email to >> [email protected] <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Android Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > *Παύλος-Πέτρος Τουρνάρης (Pavlos-Petros Tournaris)* > *Android Developer & Software Engineer* > http://about.me/pavlospt > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

