Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nontravis
Last active June 2, 2018 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nontravis/612a63dc651433215c07d90e661b7244 to your computer and use it in GitHub Desktop.
Save nontravis/612a63dc651433215c07d90e661b7244 to your computer and use it in GitHub Desktop.
CustomLayout.kt
class CustomLayout : LinearLayout {
...
@Suppress("OverridingDeprecatedMember")
override
fun fitSystemWindows(insets: Rect): Boolean {
// Pre API 20: do something with insets
return true //consume inset: not pass insets down
//or
return false //pass insets down to child view
}
@RequiresApi(Build.VERSION_CODES.KITKAT_WATCH)
override
fun onApplyWindowInsets(insets: WindowInsets): IndowInsets {
// do something with insets
return windowInsets.consumeSystemWindowInsets() //consume inset: not pass insets down
//or
return windowInsets //pass insets down to child view
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment