Skip to content Skip to sidebar Skip to footer

Webview Doesn't Display Text With Color

In my app I display some Html content in webview: String webViewConent = 'this is some sample string' webView.loadData(omowienie, 'te

Solution 1:

Same problem here, I found base64 encoding as a quick fix:

String base64 = android.util.Base64.encodeToString(html.getBytes("UTF-8"), android.util.Base64.DEFAULT);
mWebView.loadData(base64, "text/html; charset=utf-8", "base64");

Solution 2:

I had the same issue today. As a simple workaround I replaced hex colors in CSS by RGB equivalents.

Before

<spanstyle="color: #3050c0">Some text</span>

After

<spanstyle="color: rgb(48, 80, 192)">Some text</span>

Solution 3:

I found the approach in this answer on WebView encoding seems to fix this issue. Instead of using loadData, try loadDataWithBaseURL:

webview.loadDataWithBaseURL(null, html, "text/html; charset=utf-8", "utf8", null)

Solution 4:

I have same problem. My app does not display text after span tag. Some devices works fine but some devices does not work. Upvoted!

<p><spanstyle="color:#0000CD"><strong>Materials:</strong></span></p>

As a result of my research and experimentation, I have disabled the Android System Webview application on my device. As a result of this process, my application worked correctly. However, to me, this cannot be a solution. What are your ideas?

Solution 5:

I think the problem is the new update in Android Webview System. The old version works for me.

My alternative solution here is to uninstall Android Webview System in your phone so that you can have the default version(this solution is not ideal if your app is uploaded in Google Playstore and have a lot of users)

The second option is you can delete your color and background color codes in html for the meantime and it will work(I think it is Android Webview System's bug and we just need to wait until they fix their issues)

Post a Comment for "Webview Doesn't Display Text With Color"