Serhii Ostrovskyi
Serhii Ostrovskyi

Reputation: 71

Android Automotive OS: Action icon custom background

I'm using ActionStrip in NavigationTemplate to display Action objects (https://developer.android.com/reference/kotlin/androidx/car/app/model/Action) as FABs, but I can't understand how to set a custom background to it: it is always a light gray rectangle with rounded corners. Action is a final class so I can't create a custom one.

Upvotes: 0

Views: 435

Answers (1)

Grey
Grey

Reputation: 126

As far as I know, you can't change the color of your Action objects inside the ActionStrip, because following exception will be thrown: java.lang.RuntimeException: java.lang.IllegalArgumentException: Action strip actions don't support background colors

About the Action.setBackgroundColor(CarColor) method: The method is kinda broken, most likely it is overwritten by the skin of the emulator (whether it is the built-in, Polestar or Volvo one).

If you want to change the color of your whole application, then (in Android Studio) work with the Resource Manager or make dedicated UI elements.

Here you can read about Resources from Google Devs

Upvotes: 1

Related Questions