Changing the Chromecast icon color by styling MediaRouteButton

Ever since Chromecast has been added as a standard functionality to mobile applications, designers want to apply a brand color to the standard cast icon.

The only way (without the support library) is to copy assets from mediarouter library, edit as needed and override the default assets or style.

While a simple fix, it’s time consuming and over engineering for a simple color change.

color scheme Changing the Chromecast icon color by styling MediaRouteButton

Android developers stopped hacking with overrides when the v7 mediarouter library added setRemoteIndicatorDrawable to the MediaRouteButton.

The second step on the right path is the setTint method, the problem is the MediaRouteButton’s drawable is not accessible in the standard way.

But it can be done, if one knows the inner workings of the support library:

Put the two together and a simple, no hacks, no custom components solution emerges:

Check out the full demo, with a color picker and Toolbar menu cast icon on:

https://github.com/andrei-egeniq/android-tibits/tree/master/CastColor

Share

Leave a comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.