A practical guide to handling Android WindowInsets when drawing behind system bars like the navigation bar. Covers common pitfalls with OnApplyWindowInsetsListener (padding being overwritten or accumulated on repeated dispatches), introduces a doOnApplyWindowInsets() Kotlin extension that snapshots initial padding values, and wraps everything in Data Binding adapters (paddingBottomSystemWindowInsets, etc.) so inset handling can be declared directly in XML layouts with support for all four dimensions and any combination thereof.
Table of contents
Becoming a master window fitter 🔧Drawing behind the navigation bar #Handling insets through padding #doOnApplyWindowInsets #Wrapping it up in a bind #Ergonomics FTW #2 Impressions