前言
这是我写的第一篇博客,第一次写真不知道些什么。而我刚接触Android不久,也写不出什么很好的东西,不过我想了很久,还是决定写写博客,再不济我也可以把平时学的小东西写出来当做个笔记,以后自己看看也好。
使用SDK中已有的ImageGetter来显示html中的图片
//mTv是你显示html所使用的TextView
mTv.setText(Html.fromHtml("要显示的html", imageGetter, null));
/** * html显示 */
private Html.ImageGetter imageGetter = new Html.ImageGetter() {
@Override
public Drawable getDrawable(String s) {
//字符串s是html中的图片链接
LogUtils.i("test", s);
InputStream is = null;
try {
URL url = new URL(s);
is = url.openStream();
Drawable d = Drawable.createFromStream(is, "image.jpg");
//限制图片显示位置和大小
d.setBounds(0, 0, d.getIntrinsicWidth(),
d.getIntrinsicHeight());
is.close();
return d;
} catch (Exception e) {