在TextView 中添加网络获取的图片
<TextView android:id="@+id/tv_04"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f5f5f5"
android:layout_below="@+id/tv_03"
android:text="网络图片"
android:textSize="23dip"
android:textColor="#000000"/>
/**文字前后添加网络图片*/
String url="http://wiki.huihoo.com/images/2/28/Android-Robot.jpg";
TextView tv04 = (TextView)findViewById(R.id.tv_04);
ImageGetter imgGetter2 = new Html.ImageGetter() {
public Drawable getDrawable(String source) {
Drawable drawable = null;
URL url;
try {
url = new URL(source);
drawable = Drawable.createFromStream(url.openStream(), "");
} catch (Exception e) {
return null;
}
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
return drawable;
}
};
tv04.append(Html.fromHtml("网络下载的图片加上空格防止不"
+"到换行的时候字就因为图片的原因被换行 <img src=\""+url+"\">此处也可以加文字",imgGetter2, null) );
在TextView 中添加网络获取的图片
猜你喜欢
转载自wwwz.iteye.com/blog/2040708
今日推荐
周排行