Skip to content

Instantly share code, notes, and snippets.

@hiking93
Created March 16, 2022 08:41
Show Gist options
  • Save hiking93/77e6018fa2952b8d16347627a962b608 to your computer and use it in GitHub Desktop.
Save hiking93/77e6018fa2952b8d16347627a962b608 to your computer and use it in GitHub Desktop.
Use `OnApplyWindowInsetsListener` to get window insets.
class EdgeToEdgeActivity : ViewBindingActivity<ActivityMainBinding>() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupWindow()
}
private fun setupWindow() {
WindowCompat.setDecorFitsSystemWindows(window, false)
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
TODO("Handle window insets here.")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment