In systems lower than 4.4, we usually listen to the webview sliding end as follows:
1. Repeat webview and FoundWebView
Public class FoundWebView extends WebView {ScrollInterface mt; public FoundWebView (Context context) {super (context); // TODO Auto-generated constructor stub} public FoundWebView (Context context, AttributeSet attrs, int defStyle) {super (context, attrs, defStyle);} public FoundWebView (Context context, AttributeSet attrs) {super (context, attrs ); // TODO Auto-generated constructor stub} @ Override protected void onScrollChanged (int l, int t, int oldl, int oldt) {super. onScrollChanged (l, t, oldl, oldt); // Log. e ("hhah", "" + l + "" + t + "" + oldl + "" + oldt); mt. onSChanged (l, t, oldl, oldt);} public void setOnCustomScroolChangeListener (ScrollInterface t) {this. mt = t;}/*** defines the sliding interface * @ param t */public interface ScrollInterface {public void onSChanged (int l, int t, int oldl, int oldt );}}
2. Few people do not customize webview. It is too painful to directly call the system to load webview in an activity.
MWebView. setOnCustomScroolChangeListener (new ScrollInterface () {@ Override public void onSChanged (int l, int t, int oldl, int oldt) {// TODO Auto-generated method stub webviewHight = mWebView. getContentHeight () * mWebView. getScale (); // if (int) webviewHight = (mWebView. getHeight () + mWebView. getScrollY () {} // It is already at the top. // if (mWebView. getScaleY () = 0 ){////}}});
3. the operation can be performed at the bottom and top, but in the 4.4 system, I found that the height obtained in any way would be like this.
(int)webviewHight > mWebView.getHeight() + mWebView.getScrollY()
I found that the difference is always 1 on one mobile phone, but not on other mobile phones.
4. It cannot be solved at present, but considering the display at the bottom, I made an offset directly here,
MWebView. setOnCustomScroolChangeListener (new ScrollInterface () {@ Override public void onSChanged (int l, int t, int oldl, int oldt) {// TODO Auto-generated method stub webviewHight = mWebView. getContentHeight () * mWebView. getScale (); // Add a "<10" if (int) webviewHight-(mWebView. getHeight () + mWebView. getScrollY () <10) {// It is already at the bottom 10 offset} // It is already at the top // if (mWebView. getScaleY () = 0 ){////}}});
This can also solve the problem where you operate the 4.4 system at the bottom (in fact, it is not entirely at the bottom)