Issue
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?
Solution
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.
Answered By - nuevo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.