WebView the difference between loading complete and display completion

Source: Internet
Author: User

Reprint please add address: http://blog.csdn.net/jing110fei/article/details/46649079

Thought to summarize, is because the project encountered such a problem, in a layout has a webview, followed by WebView has a button, when entering this page, because WebView is not loaded out of the reason, the top of the page first shows the button, When the WebView loading is complete, you can see the move of the button clearly.

In order to solve this problem, I first want to gone the button, and then do a monitoring, and so on after the webview load is completed and then display the button,

So

Mwebview.setwebviewclient (New Webviewclient ()  {      @Override public  void onpagefinished (WebView view, String URL)   {  //end  super.onpagefinished (view, URL);  }    @Override public    void onpagestarted (WebView view, String URL, Bitmap favicon)     {    //start    super.onpagestarted (view, URL, favicon);    }  );  
There is no logical problem, but the actual effect, but the appearance of the spirit of the phenomenon.

When I'm not judging, it's because WebView reads data from the cache, which causes the end of the listening load to be inaccurate.

I set the WebView not to read from the cache, and every time I go to the network to get

But still useless, the final analysis of the load done here should refer to the WebView to load the Web page or get the data after the success, even if the load is complete,

And the effect we want is to hear the WebView show the data we want, and then let the button show up,

So I tried to customize WebView

public class Mywebview extends webview{public      interface playfinish{          void after ();      Playfinish DF;      public void Setdf (Playfinish playfinish) {          this.df = playfinish;      }      Public Mywebview (context context, AttributeSet Attrs) {          Super (context, attrs);      }      Public Mywebview (Context context) {          super (context);      }      OnDraw indicates that the display is complete      @Override      protected void OnDraw (canvas canvas) {          super.ondraw (canvas);          Df. After ();      }  }  

Private Mywebview Mywebview;
MYWEBVIEW.SETDF (New Playfinish () {      @Override public      Void after () {  btn_submit.setvisibility ( view.visible);    }  );  

Then test, work Gaocheng, rewrite OnDraw (), in the application WebView when the content starts to draw the time to let our button display, solve the problem.

Welcome to the Exchange.


WebView the difference between loading complete and display completion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.