Android: Making a button visible once webview is done scrolling

后端 未结 5 1039
面向向阳花
面向向阳花 2020-12-19 10:18

I have a webview which shows an html file. When the user scrolls to the bottom of this file in webview, I want a button that was previously hidden to show up, which the user

5条回答
  •  北海茫月
    2020-12-19 10:34

    [I can't comment on an answer, so leaving my comment here as a new answer]

    karora's answer (the first) works very well, except that in the

    protected void onScrollChanged(int left, int top, int oldLeft, int oldTop)
    

    method, calling

    getContentHeight()
    

    was wildly inaccurate for me. It reported a value much too small, so my listener was called when the user had only scrolled maybe a third of the way down the WebView. I used

    computeVerticalScrollRange()
    

    instead, and that is perfect. Thanks to this post for that helpful hint.

提交回复
热议问题