Created
May 20, 2022 09:09
-
-
Save marius-m/caa284e736bf14db0adba233d953c017 to your computer and use it in GitHub Desktop.
Dynamically apply padding to view. Useful in RecyclerView with comples item composition.
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
/** | |
* Dynamically applies padding | |
*/ | |
fun View?.applyPadding( | |
paddingStart: Int? = null, | |
paddingEnd: Int? = null, | |
paddingTop: Int? = null, | |
paddingBottom: Int? = null, | |
) { | |
this?.setPadding( | |
paddingStart ?: this.paddingStart, | |
paddingTop ?: this.paddingTop, | |
paddingEnd ?: this.paddingEnd, | |
paddingBottom ?: this.paddingBottom, | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment