Skip to content

feat: add Android gradient backgrounds#188

Merged
V3RON merged 7 commits into
mainfrom
feat/android-gradient-backgrounds
Jun 9, 2026
Merged

feat: add Android gradient backgrounds#188
V3RON merged 7 commits into
mainfrom
feat/android-gradient-backgrounds

Conversation

@V3RON

@V3RON V3RON commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What is this?

This PR adds Android support for gradient widget backgrounds through the existing style.backgroundImage API shape. Android Voltra widgets can now render CSS gradient strings as bitmap-backed Glance backgrounds without changing layout structure, and the example app includes an Android gradient playground for previewing the behavior.

How does it work?

backgroundImage is parsed into a native gradient model, rendered into a capped bitmap with Android shaders, and applied via GlanceModifier.background(ImageProvider(bitmap), ContentScale.FillBounds). The implementation supports linear, radial, and conic gradients, keeps backgroundColor as the layer behind transparent gradient pixels, and leaves the previous backgroundColor path unchanged when no gradient is present.

The Android example screen mirrors the iOS gradient playground but renders through VoltraWidgetPreview and VoltraAndroid, so it exercises the Glance widget path and uses style.backgroundImage instead of the iOS backgroundColor gradient path.

Why is this useful?

This brings gradient backgrounds to Android widgets while avoiding wrapper layouts, extra child nodes, and Glance child-count edge cases. It keeps the public API small, preserves compatibility for existing styles, bounds bitmap rendering so widget updates do not create oversized RemoteViews payloads, and gives developers a dedicated example screen for manual Android verification.

V3RON added 7 commits June 8, 2026 13:53
Adds Android backgroundImage gradient parsing and bitmap rendering for Glance widgets.

Includes generated short-name support and native parser/renderer coverage.
Adds an example app screen for previewing Android widget backgroundImage gradients through VoltraWidgetPreview.
Caps rendered gradient backgrounds by byte budget and moves the Android gradient example into the Others section.
Removes the solid backgroundColor card from the Android gradient playground so the screen focuses on backgroundImage gradients.
Documents Android backgroundImage gradient support and adds a legacy style compatibility guard.
Keeps Android gradient documentation in the website docs while removing it from the package README.
Clarifies that dynamic color tokens in Android gradients are resolved into generated bitmaps during widget rendering.
@Angelk90

Angelk90 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@V3RON : Will backgroundImage only be supported by VoltraAndroid.Box?

@V3RON

V3RON commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@V3RON : Will backgroundImage only be supported by VoltraAndroid.Box?

No, it also works fine for Column and Row - probably for most components, if not all of them.

@V3RON V3RON merged commit fb7810b into main Jun 9, 2026
12 checks passed
@V3RON V3RON deleted the feat/android-gradient-backgrounds branch June 9, 2026 06:44
@Angelk90

Copy link
Copy Markdown
Contributor

@V3RON : If you can release 2.0.0-rc.5, I'll try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants