In systems below 4.4, we usually listen to the webview slide to the end of the method as follows:
1, first re-webview,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 ol DT) {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, very few people do not customize the WebView bar, directly call the system always have a address bar too much pain, so it is generally in an activity to load WebView
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.g Etscale (); Already at the bottom if ((int) Webviewhight = = (Mwebview.getheight () + mwebview.getscrolly ())) { } //is already at the top// if ( Mwebview.getscaley () = = 0) {//// }} );
3, at the bottom and the top can be operated, but in 4.4 of the system, I found that regardless of the height obtained will be like this
(int) webviewhight > mwebview.getheight () + mwebview.getscrolly ()
On a test phone found that the difference is always 1, no other phone test
4, currently cannot be solved, but considering the bottom display, I have directly made an offset 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.g Etscale (); To resolve 4.4 The system cannot get the correct height plus a "<10" if ((int) webviewhight-(Mwebview.getheight () + mwebview.getscrolly ()) < 10) { //already at bottom 10 offset } Already at the top// if (mwebview.getscaley () = = 0) {////}}} );
This can also solve the 4.4 system you operate at the bottom (actually not completely at the bottom)