Dynamic colors
Voltra supports Android dynamic colors through semantic tokens exposed from voltra/android.
These colors follow the current Android Material palette, so widgets can pick up wallpaper and theme changes without waiting for JavaScript to run again.
Importing dynamic colors
AndroidDynamicColors includes these roles:
primaryonPrimaryprimaryContaineronPrimaryContainersecondaryonSecondarysecondaryContaineronSecondaryContainertertiaryonTertiarytertiaryContaineronTertiaryContainererrorerrorContaineronErroronErrorContainerbackgroundonBackgroundsurfaceonSurfacesurfaceVariantonSurfaceVariantoutlineinverseOnSurfaceinverseSurfaceinversePrimarywidgetBackground
Example
Where you can use them
You can use AndroidDynamicColors.* anywhere Android accepts a color value, including:
style.backgroundColorstyle.colorImage.tintColor- button
backgroundColorandcontentColor TitleBar.textColorandTitleBar.iconColor- switch, checkbox, and radio button colors
- progress indicator colors
- chart mark colors
Server-driven widgets
Dynamic color tokens work in server-rendered Android widgets too.
The same AndroidDynamicColors.* values work whether the widget is rendered in-app or returned from your server.
Migration notes
Voltra no longer uses the old Android dynamic palette snapshot approach.
- Use
AndroidDynamicColors.*for Android widgets that should react to system palette changes. - Keep using literal colors when you want a fixed color.
- There is no
useAndroidDynamicColorPalette()orgetAndroidDynamicColorPalette()API anymore.
