Horrible things can result from calling requestLayout() during a layout pass. DON'T DO THIS.
The demo that I wrote to show why this is bad seems very contrived, but I have since run across application code that did nearly the exact same thing, explicitly calling requestLayout() during onLayout(). Ugh. Typically, the cases where this problem occurs are a tad more subtle than that.
YouTube: https://www.youtube.com/watch?v=HbAeTGoKG6k
Code: http://developer.android.com/shareables/devbytes/RequestDuringLayout.zip
The demo that I wrote to show why this is bad seems very contrived, but I have since run across application code that did nearly the exact same thing, explicitly calling requestLayout() during onLayout(). Ugh. Typically, the cases where this problem occurs are a tad more subtle than that.
YouTube: https://www.youtube.com/watch?v=HbAeTGoKG6k
Code: http://developer.android.com/shareables/devbytes/RequestDuringLayout.zip
Comments
Post a Comment