Android Ktx Wait for Layout Change Callback/Event

Jul 25, 2018
Execute when view is rendered
view.updateLayoutParams {    this.width = newWidth}Log.d(TAG, "oldWidth=${view.width}")view.doOnLayout {    Log.d(TAG, "newWidth=${view.width}")}

doOnLayout

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.

doOnNextLayout

Performs the given action when this view is next laid out.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.