如何在 Android TextView 中显示 HTML img 标签
How to display HTML img tag inside Android TextView
嗨,我是 android
开发的新手。我有一个 string
看起来像这样
String source = "Hi <b>Ram</b>. This is the Formula <img src=\"https://i.postimg.cc/wTXjVKDf/ste.png\"/> Check it Out";
我想在TextView
中显示它。我用了
textView.setText(Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY));
实现这一目标。
但它看起来像这样
而不是Image
,有一个color box showing
。我在 Stack Overflow 中看到了几个问题。但所有答案都已过时。现在这些答案不起作用。请帮我解决这个问题。
文本视图将无法显示图像。您应该使用网络视图。
您应该使用 WebView
而不是 TextView
WebView = findViewById(R.id.WebView);
WebView.loadData(source, "text/html", "utf-8");
你会得到相同的输出。
嗨,我是 android
开发的新手。我有一个 string
看起来像这样
String source = "Hi <b>Ram</b>. This is the Formula <img src=\"https://i.postimg.cc/wTXjVKDf/ste.png\"/> Check it Out";
我想在TextView
中显示它。我用了
textView.setText(Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY));
实现这一目标。
但它看起来像这样
而不是Image
,有一个color box showing
。我在 Stack Overflow 中看到了几个问题。但所有答案都已过时。现在这些答案不起作用。请帮我解决这个问题。
文本视图将无法显示图像。您应该使用网络视图。
您应该使用 WebView
而不是 TextView
WebView = findViewById(R.id.WebView);
WebView.loadData(source, "text/html", "utf-8");
你会得到相同的输出。