material-components-android
material-components-android copied to clipboard
[CollapsingToolbarLayout] Calculate texts positions only in onLayout()
The PR removes the call to the updateTextBounds()
method from onMeasure()
.
Also, the PR removes all hacks (meaning the forceRecalculate
flag and passing fake view position parameters to updateTextBounds()
) that were required only for updateTextBounds()
to work in onMeasure()
.
As a nice side effect, it saves onMeasure()
from expensive, pointless, and unnecessary calculations that the CollapsingTextHelper#recalculate()
method does.
Hi can you provide more information like why we need this change and what it is aiming to solve?
In short, you can't "update text bounds" in the onMeasure()
method, because you don't know the view position yet. Well, and trying to update text bounds in the onMeasure()
method is logically incorrect, of course.
P.S. Added a little description to the PR.
Hunter, can you help take a look?
any news?
Bump.
In addition to the above description, this PR also unlocks the ability to create other PRs that fix some cases of incorrect behavior of CollapsingToolbarLayout
.