Skip to content

Instantly share code, notes, and snippets.

@5ZSQ
Created July 29, 2017 09:58
Show Gist options
  • Save 5ZSQ/5d170fbe3a3453b2655d95ccc59ec398 to your computer and use it in GitHub Desktop.
Save 5ZSQ/5d170fbe3a3453b2655d95ccc59ec398 to your computer and use it in GitHub Desktop.
Android - 设置icon颜色
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