Created
July 28, 2021 18:14
-
-
Save Ahmad-Hamwi/10b9e9dec5845c43f0d5ebf8de8736a4 to your computer and use it in GitHub Desktop.
A useful binding adapter that stretch the views boundaries to draw behind the system bar insets (aka going edge-to-edge)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* example: | |
* | |
* <!--parent container (that's expanded to fullscreen)--> | |
* <androidx.constraintlayout.widget.ConstraintLayout | |
* android:layout_width="match_parent" | |
* android:layout_height="match_parent" | |
* ... | |
* app:setDecorFitSystemWindow="@{true}"> | |
* ... | |
* ... | |
* ... | |
* </androidx.constraintlayout.widget.ConstraintLayout> | |
*/ | |
@BindingAdapter("app:setDecorFitSystemWindow") | |
fun setDecorFitSystemWindow(view: View, apply: Boolean) { | |
if (!apply) return | |
if (view.context is Activity) { | |
WindowCompat.setDecorFitsSystemWindows((view.context as Activity).window, false) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment