1

Hi I am new to android development. I have a string which looks like this

String source = "Hi <b>Ram</b>. This is the Formula <img src=\"https://i.postimg.cc/wTXjVKDf/ste.png\"/> Check it Out";

I want to display it in TextView. I used

 textView.setText(Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY));

to achieve this.
But it Looks like this enter image description here

Instead of Image, there is a color box showing. I saw several questions in Stack Overflow. But all answers are outdated. Now those answers are not working. Please help me to solve this problem.

Durai DD
  • 189
  • 1
  • 10
  • https://stackoverflow.com/questions/2865452/is-it-possible-to-display-inline-images-from-html-in-an-android-textview – Usama Altaf May 09 '22 at 11:36

2 Answers2

3

You should use WebView instead of TextView

   WebView = findViewById(R.id.WebView);
   WebView.loadData(source, "text/html", "utf-8");

You will get the same output.

Ganesh MB
  • 1,109
  • 2
  • 14
  • 27
-1

The textview will not be able to display images. You should use a webview.