Android drawable turns black and white when changed programatically

Viewed 12

I have a Floating action button that has a drawable as a source looking like this (the chef button) -

enter image description here

Later on in my app I change it's source programatically to another source, and then back to the original source with this code -

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        HomePageActivity.getChefButton().setImageDrawable(getResources().getDrawable(R.drawable.chef_white, getContext().getTheme()));
    } else {
        HomePageActivity.getChefButton().setImageDrawable(getResources().getDrawable(R.drawable.chef_white));
    }

but then it looks like this -

enter image description here

Any ideas on how to prevent this?

1 Answers

Found the solution.

I added -

  app:tint="@null"

to the floating button and it worked.

Related