Issue
I have an icon in png in drawable. It's black with the transparent background. How can I change the icon color without adding another drawable?
Solution
You can use a ColorFilter to change the icons color at runtime.
Try something like this:
Drawable mIcon= ContextCompat.getDrawable(getActivity(), R.drawable.your_icon);
mIcon.setColorFilter(ContextCompat.getColor(getActivity(), R.color.new_color), PorterDuff.Mode.MULTIPLY);
mImageView.setImageDrawable(mIcon);
Answered By - W3hri
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.