Search code examples
androidglance-appwidget

GlanceAppWidget with clickable row: inner elements steal focus and clicks


I have a widget made with a android glance library. There is a Row contains Image and Text. I need to make this row clickable.

 Row(
        verticalAlignment = Alignment.CenterVertically,
        modifier = GlanceModifier.fillMaxWidth().clickable(
            actionStartActivity(
                createOpenActivityIntent(
                   context = LocalContext.current
                )
            )
        )
    ) {
        Image(
            modifier = GlanceModifier.padding(end = 8.dp),
            provider = ImageProvider(R.drawable.ic_open),
            contentDescription = null
        )
        Text(
            text = LocalContext.current.getString(
                R.string.open
            )
        )
    }

The problem is that the row reacts to click only when I click on its area around of the Text and Image. If I click the Image or Text, nothing happens


Solution

  • It's a known bug in Glance 1.0.0-alpha04. You can downgrade to 1.0.0-alpha03 for now, and it should hopefully be fixed in the next release

    Update: Here's a link to my post on the issue tracker, but there are a few others. And't it currently marked as "fixed", so it'll hopefully be working again in 1.0.0-alpha06