Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Jetpack Glance widget works without XML? How does it convert to RemoteViews?

Jetpack released a tool called "Glance" that we can replace RemoteViews XML widgets.

I wonder how it converts compose layouts to RemoteViews.

like image 781
Ayaka_Ago Avatar asked Nov 28 '25 12:11

Ayaka_Ago


1 Answers

It does use XML underneath. It uses compose runtime to parse the node-tree, then it takes the corresponding pre-generated XML file and uses remoteviews to modify it's attributes. Then it composes everything into a single RemoteView that is sent to the AppWidget manager.

You can dive in into the code yourself. It's open source ;) https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:glance

like image 78
Marcel Avatar answered Nov 30 '25 06:11

Marcel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!