Last active
August 14, 2020 14:02
-
-
Save toe-lie/127c19262a6c51e4d011650e9f377de3 to your computer and use it in GitHub Desktop.
Vector Drawable related code to support devices below 5.0
This file contains hidden or 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
// To read vector drawable from xml attribute | |
val drawableResId = arr.getResourceId(R.styleable.GreenWayCountTextView_icon, -1) | |
if (drawableResId != -1) { | |
AppCompatResources.getDrawable(getContext(), drawableResId)?.let { drawable -> | |
setIcon(drawable) | |
} | |
} | |
// set drawable tint | |
TextViewCompat.setCompoundDrawableTintList(this, | |
ColorStateList.valueOf(ContextCompat.getColor(context, R.color.app_inactive_icon))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment