EDIT: This bug was fixed in Compose 2025.08, nested scrolling inside AndroidViews now works out of the box, see https://android-developers.googleblog.com/2025/08/whats-new-in-jetpack-compose-august-25-release.html.
In my custom Android launcher I have a compose AndroidView containing an AppWidgetHostView inside of a vertically scrollable compose Column.
This is my code, the WidgetComposable is contained in a Column with the verticalScroll() modifier:
@Composable
fun WidgetComposable(
widget: Widget,
widgetsViewModel: WidgetsViewModel
) {
val context = LocalContext.current
BoxWithConstraints(
modifier = Modifier
.fillMaxWidth()
.height(250.dp)
.scrollable(
state = rememberScrollableState { it },
orientation = Vertical
)
) {
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = {
widgetsViewModel.getViewForWidget(widget, context)
.apply {
ViewCompat.setNestedScrollingEnabled(this, true)
}
},
update = { widgetView ->
widgetView.updateAppWidgetOptions(Bundle().apply {
putInt(OPTION_APPWIDGET_MIN_WIDTH, maxWidth.int)
putInt(OPTION_APPWIDGET_MIN_HEIGHT, maxHeight.int)
putInt(OPTION_APPWIDGET_MAX_WIDTH, maxWidth.int)
putInt(OPTION_APPWIDGET_MAX_HEIGHT, maxHeight.int)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
putParcelableArrayList(
OPTION_APPWIDGET_SIZES,
arrayListOf(SizeF(maxWidth.value, maxHeight.value))
)
}
})
Log.i(TAG, "Updated widget size")
}
)
}
}
private val Dp.int get() = value.toInt()
I followed the second example on how to set up nested scrolling given here: https://developer.android.com/develop/ui/compose/touch-input/pointer-input/scroll#parent-compose-child-view. However, it doesn't work for some reason, scrolling on the widgets scrolls neither the widget content nor the column. I have uploaded a minimal example of the issue on GitHub: https://github.com/UOBW/WidgetTest.
I've tried many things to get this to work, the best solution I've found is to search through the AppWidgetHostView view hierarchy for any scrollable layouts and then, if that's the case, use a custom subclass of AppWidgetHostView that calls requestDisallowInterceptTouchEvent() inside onInterceptTouchEvent(). This prevents the Column from intercepting any touch events fired on the widget. However, there are several disadvantages:
- It also intercepts horizontal scroll events
- It probably doesn't work with Jetpack Glance
- It's going to break if Google at some point decides to allow more scrollable views in widgets than those listed here
LazyColumne.g.) does not support scrollable widgets inside it by default... Now I can get it working with a few smaller problems though. Could you solve the issue yourself already? My solution works but has small drawbacks thoughAppWidgetHostViewI use theonInterceptTouchEventto detect touch down and up/cancel and use this to enable/disable the scrolling feature of myLazyColumn.