I have an android application that I am developing using the emulator running on android 2.3.3 with an embedded WebView in a framelayout nested in a linearlayout (vertical).
In my case, it was due to the fact that my webview was attempting to load a page using HTTPS where the certificate was untrusted.
You can check if this is the case in your code using the following snippet:
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
Java
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler?, error: SslError?) {
handler?.proceed()
}
Kotlin
Then, if it is the case, quickly remove the snippet and refer to the documentation to diagnose the problem further and potentially add the certificate to your keystore.
If it still Doesn't work then please try adding "http://" or "https://" before the web address and it should work.
WebSettings settings = wbView.getSettings();
settings.setDomStorageEnabled(true);
My webview was displaying a white blank square on top of it, sometimes totally blank. This only occurred when it was loading certain data.
Changing it to a RelativeLayout, and setting layout_height to match_parent worked for me.
<RelativeLayout xmlns:android=...
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/ll_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="3dp"
android:gravity="center_vertical"
android:orientation="horizontal">
.....
</RelativeLayout>
<WebView
android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/ll_title"
android:background="@color/colorYellow" />
<ProgressBar
android:id="@+id/pb_spinning"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
It might be a bit too late, but I wanted to share my experience with you, because I had the same problem and spent a lot of time on it.
Put your WebView
in RelativeLayout
and not in FrameLayout
.
What I have tested: My WebView
's onPageFinished()
was called every time, but on the screen I got blank page.
From chrome://inspect
WebView
debugger I was able to "ping" my WebView
by pressing inspect
button, and after that WebView
was refreshing immediately.
My thoughts - WebView
isn't rendered correctly in FrameLayout
, and RelativeLayout
fixes the issue (even invalidate()
and requestLayout()
calls didn't help).
instead of passing null, you should pass an empty String
to it. ex: ""
So you should call it like this:
wview.loadDataWithBaseURL("", "<HTML><BODY><H3>Test</H3></BODY></HTML>","text/html","utf-8","");