I have a DialogFragment with a WebView inside it. If the webview does not load the page fast enough, the DialogFragment will shrink completely and not show the webview. Otherwise, if the loading was fast, the WebView is shown.
I found the solution by myself. If you use LinearLayout as the root view for your DialogFragment this will happen, changing it to FrameLayout resolved the problem. I do not understand why, but it works.
I tried in two devices.
In first device Nexus 6 worked like say David "I found the solution by myself. If you use LinearLayout as the root view for your DialogFragment this will happen, changing it to FrameLayout resolved the problem. I do not understand why, but it works". But i tried in second device (Galaxy Prime) and surprise, not worked. After tried make setVisible GONE WebView in my WebViewClient inside callback onPageStarted()
and after setVisible VISIBLE inside callback onPageFinished()
and worked for my.
public class MyWebClient extends WebViewClient {
private static final String LOG_CAT = "NetPayWebClient";
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.e(LOG_CAT, "onPageStarted(): " + url);
view.setVisibility(View.GONE);
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
Log.e(LOG_CAT, "onPageFinished(): " + url);
view.setVisibility(View.VISIBLE);
super.onPageFinished(view, url);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With