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
@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