fromHtml还有另一个重构:
fromHtml(String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)


而ImageGetter imgGetter = new Html.ImageGetter() {
             @Override
             public Drawable getDrawable(String source) {
                   Drawable drawable = null;
                   drawable = Drawable.createFromPath(source);  // Or fetch it from the URL
                   // Important
                   drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable
                                 .getIntrinsicHeight());
                   return drawable;
             }
};

至于TagHandler,我们这里不需要使用,可以直接传null。

要让TextView解析和显示Html代码。可以使用
Spanned text = Html.fromHtml(source);
tv.setText(text);

 

相关文章:

  • 2021-12-09
  • 2022-02-02
  • 2021-12-04
  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2022-02-05
猜你喜欢
  • 2021-08-07
  • 2022-01-21
  • 2022-12-23
  • 2021-12-20
  • 2021-08-12
  • 2021-04-14
  • 2022-12-23
相关资源
相似解决方案