Made a widget with glance API in Jetpack Compose. Button filling the whole widget

21 Views Asked by At

I used the Glance API in Jetpack Compose to make a homescreen widget. However, when used, the button fills up the whole widget. Did as mentioned in this documentation -

https://developer.android.com/develop/ui/compose/glance/create-app-widget

implementation ("androidx.glance:glance:1.0.0")
implementation ("androidx.glance:glance-appwidget:1.0.0")

Dependency versions added

Tried the exact thing given in the documentation above

Expected Result

@Composable
    private fun MyContent() {
        Column(
            modifier = GlanceModifier.fillMaxSize(),
            verticalAlignment = Alignment.Top,
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Text(text = "hello", modifier = GlanceModifier.padding(12.dp))
            Row(horizontalAlignment = Alignment.CenterHorizontally) {
                Button(
                    text = "A",
                    onClick = actionStartActivity<MainActivity>()
                )
                Button(
                    text = "B",
                    onClick = actionStartActivity<MainActivity>()
                )
            }
        }
    }

Exact code

0

There are 0 best solutions below