In my app I display some Html content in webview:
String webViewConent = 'this is some <span style="color:#2ecc71">sample</span> string'
webView.loadData(omowienie, "text/html; charset=utf-8", "UTF-8");
However after last app update, which was related with some other thing, for some users webview doesn't work correctly. They see only string which is before span tag. The problem is not related to any specific android version.
Android App Development for BeginnersStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.
This interface was deprecated in API level 12. This interface is now obsolete.
If you want to override certain methods, you have to create a custom WebView class which extends WebView . Also, when you are inflating the WebView , make sure you are casting it to the correct type which is CustomWebView . CustomWebView webView = (CustomWebView) findViewById(R. id.
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");
I had the same issue today. As a simple workaround I replaced hex colors in CSS by RGB equivalents.
Before
<span style="color: #3050c0">Some text</span>
After
<span style="color: rgb(48, 80, 192)">Some text</span>
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