//找到TextView的控件 tv_text = (TextView) findViewById(R.id.jieshou02); //图文混排的内容 String html = "<font>你是</font><img src=‘strawberry'><font>大美女</font>"; CharSequence text = Html.fromHtml(html, new Html.ImageGetter() { public Drawable getDrawable(String source) { //根据图片资源ID获取图片 Log.d("source", source); if (source.equals("‘strawberry'")) { //获取一张图片 Drawable draw = getResources().getDrawable(R.mipmap.account_icon_kaixin); draw.setBounds(0, 0, draw.getIntrinsicWidth(), draw.getIntrinsicHeight()); return draw; } return null; } }, null); tv_text.setText(text);
Android使用TextView图文混排
最新推荐文章于 2022-05-26 15:44:55 发布