Bpn
Bpn

Reputation: 693

WebView content inside of bottom sheet of the ModalBottomSheetLayout is not scrollable

I am trying to implement WebView in a ModalBottomSheetLayout. Issue is that WebView content is not scrolling inside bottom sheet. It works fine in normal compose view. Couldn't find anything workable. Is there a way to make it working?

Upvotes: 5

Views: 1372

Answers (2)

Marine Droit
Marine Droit

Reputation: 161

I was facing to the same issue but adding

setOnTouchListener { v, event ->
    v.parent?.requestDisallowInterceptTouchEvent(true)
    v.onTouchEvent(event)
}

to the webView (in the apply block) is fixing the problem !

Upvotes: 0

Aamir
Aamir

Reputation: 51

Maybe this can help you? Let me know if this works for you.

    Column(
    modifier = modifier
        .fillMaxSize()
        .verticalScroll(rememberScrollState())
) {
    AndroidView(factory = {
        WebView(it).apply {
            webViewClient = WebViewClient()
            layoutParams = ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
            )
            loadUrl(url)
        }
    }, update = {
        it.loadUrl(url)
    }
    )
}

Upvotes: 2

Related Questions