这是代码, 我想要显示图像。我也试过尺寸。
TextView textViewHtml = (TextView) findViewById(R.id.text_html_program);
Spanned spanned = Html.fromHtml( "<b>text_html_program: Constructed from HTML programmatically.</b>"
+ " Text with a <a href=\"http://www.google.com\">link</a> "
+"<b><img src=\"http://innovativeprofessionaloffices.com/wp-content/uploads/2014/07/seo-for-small-business.jpg\" alt=\"testing\"></b>"
+ "created in the Java source code using HTML.");
textViewHtml.setText(spanned);
textViewHtml.setMovementMethod(LinkMovementMethod.getInstance());
答案 0 :(得分:0)
您可以使用以下模式获取img标记:
String ptr= "src\\s*=\\s*([\"'])?([^\"']*)";
Pattern p = Pattern.compile(ptr);
Matcher m;
//find the img tag
m = p.matcher(html_string_containg_img_Tag);
if (m.find()) {
m.group(2),img);//this line get the image tag from give string
}
这对你有帮助