conradchen b0f37007aa [Button] Fix icon position not being updated when size is not changed
If a button has a WRAP_CONTENT width and after its text is updated but its size does not change, the icon position won't be updated because at the moment when onTextChanged() is called, getLayout() will return null and a new layout to display text will only be recreated in the next onMeasure() call.

To fix this issue, the change moves updateIconPosition() from onSizeChanged() to onLayout(), which will always be called after onMeasure() or onSizeChanged() is called, and thus covers both of the cases after the text is updated (the button changes its size or not.)

Note: we still need to keep the updateIconPosition() call in onTextChanged(), to cover the case that the button has a fixed width, in which updating text won't trigger remeasuring of the button.

Resolves https://github.com/material-components/material-components-android/issues/2553

PiperOrigin-RevId: 427215840
2022-02-09 15:56:11 +00:00
..