How does Android WebView tell if it scrolls to the bottom
This article is about how Android WebView determines whether to scroll to the bottom or not. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Scene:
Sometimes we need to play some must-read announcements, but we may not turn it off until you have finished reading it, so we need to scroll to the bottom to display the close button, and the announcements are often based on rich text, so we need to use WebView when displaying them on Android. Based on this requirement, we have to judge whether WebView scrolls to the bottom.
Analysis:
To determine whether or not to reach the bottom, let's first analyze which cases there are. There are two situations when the html document is loaded into WebView.
The html content in WebView is not filled, that is, there is no scroll bar. The height of the html content is higher than that of the WebView control, so there is a scroll bar, that is, a scroll bar
For case 1, if there is no scroll bar, we can just display the close button, but for the second case with scroll bar, we need to calculate the height, that is, html height = WebView height + scroll bar length, then we can judge that the scroll bar has reached the bottom.
Achieve:
Html height