android - Android Webview contentHeight 具有上次访问页面的值
问题描述
当我调用 Webview.contentHeight 时,我每次都会从上次访问的站点中获取值。我该怎么做才能获得新加载网站的 contentHeight ?
我试试这个:
val view = findViewById<WebView>(R.id.view)
url = edit.text.toString()
url = URLUtil.guessUrl(url)
edit.text = url
if (URLUtil.isValidUrl(url)) {
view.loadUrl(url)
//here I've tried and give the Webview with sleep(30000) some time, but this also don't working
var cheight = view.contentHeight
var vHeight = view.height
var mheight = view.measuredHeight
var minheight = view.minimumHeight
Toast.makeText(this, cheight.toString() + " " + vHeight.toString() + " " + mheight.toString() + " " + minheight.toString(), Toast.LENGTH_SHORT).show()
解决方案
我不得不解决这个问题。为了测试之后的行为,我在 Button.Listener 中获取 ContentHeight 并使用 Toast.makeText() 显示该值。现在我得到了当前值。
推荐阅读
- flutter - Flutter 中的 RTCTokenBuilder Agora 保持说 invalidAppID
- flutter - FCM 自定义声音通知不适用于 IOS Xcode
- c# - 是否可以对 Angular 9 项目进行差异覆盖?
- c# - 用于匹配值数组或其他数组的正则表达式
- android - 关于 Glide 的 sizeMultiplier 的说明
- java - 使用 InheritableThreadLocal 的数据泄漏
- docker - 有没有办法从标准输入提供 docker-compose env-file?
- r - 我的 aggregate() 输出和 tidyverse 输出之间的区别
- php - 如何用法语显示十进制的小数部分
- swift - 通用约束