TextView tv_text = (TextView) findViewById(R.id.tv);
String html="<font>草莓</font><img src=‘ic_launcher’><font>草莓</font>";
CharSequence text=Html.fromHtml(html, new ImageGetter() {
public Drawable getDrawable(String source) {
//根据图片资源ID获取图片
Log.d("source", source);
if(source.equals("‘ic_launcher’")){
Drawable draw=getResources().getDrawable(R.drawable.ic_launcher);
draw.setBounds(0, 0, draw.getIntrinsicWidth(), draw.getIntrinsicHeight());
return draw;
}
return null;
}
}, null);
tv_text.setText(text);
TextView添加图片实现图文混排
最新推荐文章于 2019-05-25 09:12:21 发布