You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Proper way to setup attr colors
This commit is contained in:
@@ -297,3 +297,17 @@ fun CardView.setCardBackgroundColorAttr(attr: Int) {
|
||||
fun ImageView.setTint(color: Int) {
|
||||
ImageViewCompat.setImageTintList(this, ColorStateList.valueOf(color))
|
||||
}
|
||||
|
||||
@BindingAdapter("tintAttr")
|
||||
fun ImageView.setTintAttr(attr: Int) {
|
||||
val tv = TypedValue()
|
||||
context.theme.resolveAttribute(attr, tv, true)
|
||||
ImageViewCompat.setImageTintList(this, ColorStateList.valueOf(tv.data))
|
||||
}
|
||||
|
||||
@BindingAdapter("textColorAttr")
|
||||
fun TextView.setTextColorAttr(attr: Int) {
|
||||
val tv = TypedValue()
|
||||
context.theme.resolveAttribute(attr, tv, true)
|
||||
setTextColor(tv.data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user