Reputation: 2211
I am trying to reach bottom of a Webview. I am getting the height of Webview inside onPageFinished() method by,
override fun onPageFinished(view: WebView?, url: String?) {
Log.d("webview_total_height", "height " + view!!.contentHeight)
height = view!!.contentHeight
}
And on button click I am trying to reach to bottom by,
wvMain.scrollTo(0, height)
But it's scrolling to somewhere middle of webview, not reaching bottom
How will I reach to the bottom of webview?
Upvotes: 2
Views: 1991
Reputation: 324
Just replace
wvMain.scrollTo(0, height)
By
wvMain.scrollTo(0, height * getResources().getDisplayMetrics().density.toInt())
By this you will get actual height of WebView in pixels as per device screen density
I guess you will get your desired result.
Upvotes: 3