-
-
Save programmerr47/73c60c9c466df2fd88dbb55ea83bba0e to your computer and use it in GitHub Desktop.
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
val View.padding get() = ViewPadding(this) | |
inline class ViewPadding(private val view: View) { | |
var start: Int | |
get() = view.paddingStart | |
set(value) = view.setPaddingRelative(value, top, end, bottom) | |
var top: Int | |
get() = view.paddingTop | |
set(value) = view.setPaddingRelative(start, value, end, bottom) | |
var end: Int | |
get() = view.paddingEnd | |
set(value) = view.setPaddingRelative(start, top, value, bottom) | |
var bottom: Int | |
get() = view.paddingBottom | |
set(value) = view.setPaddingRelative(start, top, end, value) | |
var horizontal: Int | |
get() = start + end | |
set(value) { | |
start = value | |
end = value | |
} | |
var vertical: Int | |
get() = top + bottom | |
set(value) { | |
top = value | |
bottom = value | |
} | |
var total: Int | |
@Deprecated("No getter for that field", level = DeprecationLevel.HIDDEN) | |
get() = throw UnsupportedOperationException("No getter for such field") | |
set(value) { | |
horizontal = value | |
vertical = value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment