WebView 覆盖整个 Compose 屏幕

问题描述 投票:0回答:1
android html webview android-jetpack-compose
1个回答
1
投票

感谢来自 ComposeMpp 社区的 Yap。

需要使用

.clipToBounds()
修饰符。

AndroidView(
  modifier = Modifier
      .fillMaxWidth()
      .padding(horizontal = 16.dp)
      .clipToBounds(),
  factory = { context ->
    WebView(context).apply {
      layoutParams = ViewGroup.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.WRAP_CONTENT
      )               
      setBackgroundColor(ColorDomopult.BasicBgPrimary.toArgb())
      settings.javaScriptEnabled = true
      loadDataWithBaseURL(
        null,
        service.description ?: "",
        "text/html",
        "utf-8",
        null
      )
    }
  }
)
© www.soinside.com 2019 - 2024. All rights reserved.