fix: view-level webview scale, close menu on outside tap/page switch
This commit is contained in:
@@ -43,13 +43,17 @@ class WebViewManager(private val activity: Activity) {
|
||||
ua == "desktop" || ua == "pc" -> UA_DESKTOP
|
||||
else -> ua
|
||||
}
|
||||
// 初始缩放(1-100):用于 PC 版页面缩放适配横屏。
|
||||
// 需关闭 overview 模式,否则 useWideViewPort+overview 会自动重新缩放并覆盖 setInitialScale
|
||||
// Initial zoom (1-100): scale desktop pages to fit landscape. Must disable
|
||||
// overview mode, otherwise useWideViewPort+overview re-zooms and overrides setInitialScale
|
||||
// 缩放(1-100):View 级别 scaleX/scaleY,不依赖页面渲染或 viewport,对任何页面可靠生效。
|
||||
// 缩放后内容相对左上角缩小;触摸坐标由 View 自动映射
|
||||
// Zoom (1-100): view-level scaleX/scaleY, independent of page rendering or
|
||||
// viewport, so it reliably works for any page. Content shrinks toward the
|
||||
// top-left; touch coordinates are auto-mapped by the View
|
||||
if (scale != null && scale in 1..100) {
|
||||
webView.settings.loadWithOverviewMode = false
|
||||
webView.setInitialScale(scale)
|
||||
val s = scale / 100f
|
||||
webView.scaleX = s
|
||||
webView.scaleY = s
|
||||
webView.pivotX = 0f
|
||||
webView.pivotY = 0f
|
||||
}
|
||||
return webView
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user