这是代码,我想要显示图像。我还尝试了它的大小。
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());发布于 2017-02-23 13:54:55
您可以使用以下模式获取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
}希望这对你有帮助
https://stackoverflow.com/questions/42408022
复制相似问题