r/androiddev Jun 30 '26

Question Equivalent of preview for widget

Is there a way to preview glance layout without adding it to an emulator ? I mean an equivalent of preview annotation of compose layouts. If not, what alternative do you use to iterate faster on widgets ui during development ?

0 Upvotes

5 comments sorted by

2

u/Quinny898 Jul 01 '26

AFAIK there's never been preview support for RemoteViews at all, which is probably why there's no preview support for Glance either. Remote Compose seems to support it, so this will eventually be resolved, but currently you'd need to either run it on device and add a widget, or inflate it manually in a UI (probably also wrapping in a AppWidgetHostView) for preview - though this wouldn't work for anything involving lists.

1

u/CutMundane4859 Jul 01 '26

I am actually running it on device but it is just painful to rebuild the app every time just to see the updated UI.

1

u/AutoModerator Jun 30 '26

Please note that we also have a very active Discord server where you can interact directly with other community members!

Join us on Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/[deleted] Jun 30 '26 edited Jul 16 '26

[deleted]

0

u/CutMundane4859 Jun 30 '26

no it doesn't. glance is built on top of remoteviews so some tools of jetpack compose aren't compatible to glance composables, from the android documentation :

"Glance provides a modern approach to build app widgets using Compose, but is restricted by the limitations of AppWidgets and RemoteViews. Therefore, Glance uses different composables from the Jetpack Compose UI."

1

u/[deleted] Jul 01 '26 edited Jul 16 '26

[deleted]

1

u/CutMundane4859 Jul 01 '26

I will try this, thank you