The difference between WebView loading completion and display completion is that webview Loading
Please add address reprint: http://blog.csdn.net/jing110fei/article/details/46649079
The reason is that the project encountered such a problem. There is a WebView in a layout, followed by a Button in webView. When you enter this page, because webView is not loaded, the button is displayed at the top of the page. After webView is loaded, the button is obviously moved.
To solve this problem, I first want to drop the Button GONE and then perform a listener. After webView is loaded, the Button is displayed,
Therefore
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 logic problem, but in terms of the actual effect, there is a phenomenon of failed working.
The reason why webView reads data from the cache leads to inaccurate loading of the listener,
I set it to prevent webView from being read from the cache and retrieve it from the network each time.
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
But it is still useless. The final analysis here should refer to the loading of the web page through webView or after obtaining the data is successful,
What we want is to listen to webView to display the data we want, and then let the Button display it,
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, the test was completed, and the onDraw () was rewritten. When the content in the webView in the application starts to be drawn, the button was displayed, which solved the problem.
Welcome to the discussion.