79226846

Date: 2024-11-26 13:12:07
Score: 1
Natty:
Report link

You can see this answer : https://stackoverflow.com/a/78613211/23865791

As wrote previously, Glance previews are now supported with the latest versions of Android Studio.

You need to use Glance 1.1.0-rc01 or newer :

implementation("androidx.glance:glance:1.1.1")
implementation("androidx.glance:glance-preview:1.1.1")
implementation("androidx.glance:glance-appwidget-preview:1.1.1")
implementation("androidx.glance:glance-appwidget:1.1.1")

And add the annotations with a size for your widget preview:

@OptIn(ExperimentalGlancePreviewApi::class)
@androidx.glance.preview.Preview(widthDp = 250, heightDp = 250)
@Composable
private fun Preview() {
...
}

But for the moment the Glance previews are limited compared to Compose previews.

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Dimitri LTC