Created
July 29, 2017 09:58
-
-
Save 5ZSQ/5d170fbe3a3453b2655d95ccc59ec398 to your computer and use it in GitHub Desktop.
Android - 设置icon颜色
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
public void setRightIconDefault(int drawableId){ | |
Drawable drawable = ContextCompat.getDrawable(mContext, drawableId); | |
drawable.clearColorFilter(); | |
drawable.setColorFilter(selectColor, PorterDuff.Mode.SRC_ATOP); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | |
rightIcon.setBackground(drawable); | |
} | |
else | |
{ | |
//noinspection deprecation | |
rightIcon.setBackgroundDrawable(drawable); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment