chrisbanes / insetter

Insetter is a library to help apps handle WindowInsets more easily
https://chrisbanes.github.io/insetter
Apache License 2.0
1.13k stars 42 forks source link

Support for the Android 11 WindowInsets types #86

Closed chrisbanes closed 3 years ago

chrisbanes commented 3 years ago

The new API:

// kotlin
Insetter.builder()
    // This will apply the navigation + status bar insets as padding to
    // all sides of the view
    .padding(windowInsetTypesOf(navigationBars = true, statusBars = true))
    // There's also paddingLeft(), paddingTop(), etc for specific sides

    // This will apply the navigation bar insets as bottom margin on the view
    .marginBottom(windowInsetTypesOf(navigationBars = true))
    // Similarly, there's also margin(), marginLeft(), etc

    // Applies this to the view
    .applyToView(view)
// java
Insetter.builder()
    // This will apply the navigation + status bar insets as padding to
    // all sides of the view.
    .padding(WindowInsetsCompat.Type.navigationBars()
        | WindowInsetsCompat.Type.statusBars())
    // There's also paddingLeft(), paddingTop(), etc for specific sides

    // This will apply the navigation bar insets as bottom margin on the view
    .marginBottom(WindowInsetsCompat.Type.navigationBars())
    // Similarly, there's also margin(), marginLeft(), etc

    // Applies this to the view
    .applyToView(view);

Breaking changes