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