Webview不会显示带有颜色的文本 [英] Webview doesn't display text with color

查看:87
本文介绍了Webview不会显示带有颜色的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我在Webview中显示一些HTML内容:

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

但是,在上一次应用程序更新(与其他功能有关)之后,对于某些用户而言,网络视图无法正常运行.他们只能看到在span标签之前的字符串.该问题与任何特定的android版本无关.

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.

推荐答案

在这里存在同样的问题,我发现base64编码可以作为一种快速解决方案:

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

这篇关于Webview不会显示带有颜色的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆