Request layout when updating child layout params.
In order to clear the measure cache, we need to requestLayout when updating the child layout params. To see why, consider the case of a Frame or Linear layout which will measure different heights depending on the (top/left/right/bottom)Margin parameters of it's childrens layout params. Now imagine the following sequence of events: 1. We request a layout on the FrameLayout 2. We measure the FrameLayout and place a value in the cache. 3. Now we update the margin parameters on one of the frame layouts children. Because the parent already has a layout requested we don't call parent.requestLayout (see View.java#requestLayout), and thus the parent measure cache isn't cleared. 4. Now we measure the frame layout again and we incorrectly used the cached value. Calling to requestLayout when the child layout params change clears the cache properly. If the child didn't call request layout from it's own relayout, it must mean that a layout was already pending (step 1 in the sequence), and so no more work should be triggered besides clearing the cache. Bug: 33095565 Bug: 33308065 Bug: 34388764 Test: Manual case in bugs. Change-Id: I9148f32530588e4dc859297f9658f506b38e72f0
Loading
Please register or sign in to comment