I am having a number of problems with the new AppCompat 23.3.x and drawables. First of all, I had to go back and delete:
vectorDrawables.useSupportLibrary = true
Since AppCompat returned this now, my application generates PNG again. Well, however, I tinted the (drawableTop) button in such a way that it completely stopped working (for devices prior to M).
Here is the method I used:
private void toggleState(boolean checked) { Drawable[] drawables = getCompoundDrawables(); Drawable wrapDrawable = DrawableCompat.wrap(drawables[1]); if (checked) { DrawableCompat.setTint(wrapDrawable.mutate(), ContextCompat.getColor(getContext(), R.color.colorPrimary)); setTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary)); } else { DrawableCompat.setTint(wrapDrawable.mutate(), ContextCompat.getColor(getContext(), R.color.icon_light_enabled)); setTextColor(ContextCompat.getColor(getContext(), R.color.text_primary_light)); } }
The fact is that I have a custom Button class that can be checked if it is installed, drawableTop and text have a different color if it is not checked.
This was done (with appcompat 23.2.0), but now it is not (below Android M). Believe me or not, but by doing this when it reaches setTint , the icon no longer displays.
To make it work, I have to do the following:
DrawableCompat.setTint(wrapDrawable.mutate(), ContextCompat.getColor(getContext(),R.color.colorPrimary)); setCompoundDrawablesWithIntrinsicBounds(null, wrapDrawable, null, null);
Thus, every time I tint them, I have to call setCompoundDrawablesWithIntrinsicBounds again. It does everything to work again. However, I am a little worried about tuning every time. Basically, I am wondering if there is a better way or something that I do not see.
I know that Button has setCompoundDrawableTintList , which would be wonderful, but its minimum API is level 23.