79812027

Date: 2025-11-07 07:16:35
Score: 0.5
Natty:
Report link
BoxWithConstraints(Modifier.fillMaxSize()) {

    val width =
        if (constraints.hasFixedWidth)
            LayoutParams.MATCH_PARENT
        else
            LayoutParams.WRAP_CONTENT
    val height =
        if (constraints.hasFixedHeight)
            LayoutParams.MATCH_PARENT
        else
            LayoutParams.WRAP_CONTENT

    val layoutParams = FrameLayout.LayoutParams(
        width,
        height
    )

    AndroidView(
            modifier = Modifier
                .fillMaxSize(),
            factory = { context ->
                webViewSource = WebView(context).apply {

                    this.layoutParams = layoutParams
                    settings.javaScriptEnabled = true
                    webViewClient = object : WebViewClient() {

                    }
                    
                    loadUrl("about:blank")
                }
                webViewSource!!
            },
            update = { webView ->
            }
        )

}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: user31077472