Stack Overflow archive
1 scoreaccepted

Is there any way to enforce android.support.v7.appcompat.R.drawable.abc_ic_clear_mtrl_alpha as white color

score
1
question views
430
license
CC BY-SA 3.0

AppCompat resources can change in future updates. You should put a close button in your resources and use that drawable instead.

If you want to make the current drawable white, then you can apply a ColorFilter. Example:

java
mCloseButton.setColorFilter(Color.WHITE);

You can also apply a ColorFilter to the Drawable

java
Drawable closeDrawable = getResources().getDrawable(android.support.v7.appcompat.R.drawable.abc_ic_clear_mtrl_alpha);
closeDrawable = closeDrawable.mutate(); // don't apply the ColorFilter everywhere
closeDrawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
mCloseButton.setImageDrawable(closeDrawable);

To use your own image, you can use the vector drawable import in Android Studio or get the image from materialdesignicons.com.

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.