Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android dialogFragment "sometimes" not showing webview

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.

like image 404
David Avatar asked Nov 07 '12 17:11

David


2 Answers

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.

like image 81
David Avatar answered Nov 15 '22 01:11

David


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);
    }

}
like image 3
Heriberto Rivera Avatar answered Nov 15 '22 01:11

Heriberto Rivera