使用TextView显示图像添加链接的方法
来源:互联网 发布:网络护卫怎么卡cf手游 编辑:程序博客网 时间:2024/06/04 18:18
1.设置html字符串,其中里面包括图像src,以及链接。
2.将字符串进行序列化使用方法为:CharSequence ch=Html.formHtml(html);
3.如果需要对其中的图片进行处理,则添加ImageGetter()方法,使用Html.formHtml(....)函数。
4.将ch添加到TextView中。
5.ch中有超链接的话,在TextView中设置相应的setMovementMethod(LinkMovementMethod.getInstance())
String html = "图像1<img src='image1'/>图像1<img src='image1'/>图像2<img src='image2'/>图像3<img src='image3'/></br>";
html += "图像4<a href='http://www.baidu.com'><img src='image4'></a>图像5<img src='image5'/>";CharSequence ch=Html.fromHtml(html, new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
// TODO Auto-generated method stub
// 获得系统资源的信息,比如图片信息
Drawable drawable = getResources().getDrawable(
getResoureId(source));
// 处理第三个图片文件 按照50%的比例进行压缩
if (source.equals("image3")) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth() / 2,
drawable.getIntrinsicHeight() / 2);
}else{
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
}
return drawable;
}
}, null);
textView.setText(ch);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
0 0
- 使用TextView显示图像添加链接的方法
- TextView 显示图像+文字的方法
- 在TextView中添加其他链接的方法
- Android的TextView中显示图片和图像的方法
- Android的TextView中显示图片和图像的方法
- 使用TextView显示资源和本地的gif图像
- Android高亮显示TextView某个单词,添加链接
- Android TextView 添加链接
- TextView添加链接
- TextView 添加链接
- textView显示文字链接
- TextView图文混排,显示添加的图片,三种常用方法,亲测
- android-----使用ImageSpan对象在TextView组件中显示图像
- TextView中添加HTTP链接
- 为TextView添加链接-setMovementMethod
- TextView添加下划线的简单方法
- 添加TextView隐藏进度条的方法
- 添加TextView隐藏进度条的方法
- STL学习记录(六):List
- jquery用户自定义选择器及选择器高级用法实验
- 毕设(排课系统)笔记1---用户注册(二)
- JAVA程序设计基础教程 异常处理
- 输出一个学生的成绩数组,该数组中有五个学生的数据记录
- 使用TextView显示图像添加链接的方法
- SDKD 14级组队练习赛(一) J 递归打印图案
- 2015山东省赛B题-sdut3252---Lowest Unique Price
- Fedora13下真正能用的源(2015-5-16亲测)
- 回溯法:八皇后问题
- spring mvc 多视图配置
- POJ 3669 Meteor Shower
- [leetcode][math] Plus One
- 20150517