When you make changes to view size or text size programatically, the UI changes are not rendered immediately. How do you know when the new size has actually rendered?
Performs the given action when this view is laid out. If the view has been laid out and it has not requested a layout, the action will be performed straight away, otherwise the action will be performed after the view is next laid out.
NOTE: if you are not using Kotlin or android-ktx, you can look into the source code which uses addOnLayoutChangeListener
.
// change layout widthpreviewLayout.updateLayoutParams { width = 300}// still showing old widthLog.d(TAG, width=${previewLayout.width}")previewLayout.doOnLayout { // new width Log.d(TAG, "doOnLayout.width=${previewLayout.width}")}