Skip to content

Instantly share code, notes, and snippets.

View fercarcedo's full-sized avatar

Fernando García Álvarez fercarcedo

View GitHub Profile
// Old way (now deprecated) of requesting the app to be
// laid out fullscreen and hiding the navigation
view.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// New way of requesting the app to be laid out fullscreen
// (for example, when implementing edge-to-edge)
window.setDecorFitsSystemWindows(false)
// You have to wait for the view to be attached to the
// window (otherwise, windowInsetController will be null)
view.doOnLayout {
view.windowInsetsController?.show(WindowInsets.Type.ime())
// You can also access it from Window
window.insetsController?.show(WindowInsets.Type.ime())
}
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Rest of the theme attributes... -->
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
window.insetsController?.controlWindowInsetsAnimation(
WindowInsets.Type.ime(),
-1,
null,
listener
)