androidandroid-auto

How to set Android Auto media app button color


I'm developing a media app with support for Android Auto and I'm having troubles with the styling. In the attached image, the Spotify app has the button colored with the Spotify green color: how did the do that? In my app that button has a default "teal" color (that of course I haven't defined anywhere). The same color is also used for styling the progress indicator in the Now Playing page (second attached image). I searched in the official documentation but they never explain how to style those elements.

I tried to set the primary color of my app theme, but that doesn't seem to make a difference.

Spotify Android auto app with green button

Spotify Android auto app with green progress indicator

Thanks in advance for your help!


Solution

  • I had a look at the source code of Android Auto here: https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/heads/android10-release/car-media-common/src/com/android/car/media/common/source/MediaSourceColors.java

    and I discovered that it should use your application theme accent color, but in my case it wasn't working, I don't know why.

    In the source code I also discovered that you can define a custom theme just for the car app by specifyng the following meta in your manifest:

    <meta-data android:name="com.google.android.gms.car.application.theme"
                android:resource="@style/CarTheme" />
    

    And this is working!