android 图文混排,显示网络图片

在TextView中显示如下文本:
"content":"使用editor.getContent()方法可以获得编辑器的内容内容为:<h1 style=\"font-size: 32px; font-weight: bold; border-bottom: 2px solid rgb(204, 204, 204); padding: 0px 4px 0px 0px; text-align: center; margin: 0px 0px 20px;\">原理实践</h1><p><br/></p><p><a class=\"edit-icon j-edit-link\" style=\"font-family: SimSun; color: rgb(136, 136, 136); display: block; float: right; height: 22px; line-height: 22px; padding-left: 24px; font-size: 12px; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span class=\"cmn-icon wiki-lemma-icons wiki-lemma-icons_edit-lemma\" style=\"font-family: baikeFont_layout; -webkit-font-smoothing: antialiased; speak: none; line-height: 1; outline: 0px; margin: 0px 3px 0px 0px; vertical-align: text-bottom; color: rgb(170, 170, 170);\"></span>编辑</a></p><p><br/></p><p>富文本编辑器,Rich Text Editor, 简称 RTE, 它提供类似于 Microsoft Word 的编辑功能,容易被不会编写 HTML 的用户并需要设置各种文本格式的用户所喜爱。它的应用也越来越广泛。最先只有 IE 浏览器支持,其它浏览器相继跟进,在功能的丰富性来说,还是 IE 强些。虽然没有一个统一的标准,但对于最基本的功能,各浏览器提供的 API 基本一致,从而使编写一个跨浏览器的富文本编辑器成为可能。<br/></p><p><a class=\"image-link\" href=\"http://baike.baidu.com/pic/%E5%AF%8C%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8/10954999/0/4abae5ed1e41297878f055f9?fr=lemma&ct=single\" target=\"_blank\" title=\"\" style=\"color: rgb(19, 110, 194); text-decoration: none; display: block; width: 250px; height: 116px;\"><img class=\"\" src=\"http://f.hiphotos.baidu.com/baike/s%3D250/sign=091b9b0233fa828bd5239ae6cd1f41cd/5366d0160924ab18220efe3035fae6cd7b890b98.jpg\" alt=\"\"/></a></p><p>在很多开发者看来,富文本编辑器的编写是一件很神秘或者复杂的事情。神秘倒没有,复杂的话,确实如此。但是它的基本原理并不复杂,入门也不难。今天我们的主题是讲述基本原理,并逐步演示一个简单富文本编辑器的产生。这是我在<a target=\"_blank\" href=\"http://baike.baidu.com/view/399003.htm\" style=\"color: rgb(19, 110, 194); text-decoration: none;\">D2</a>上的一个分享内容,在台上的演讲效果不佳,固写下来,希望能够对感兴趣的读者有所帮助。</p><p><br/></p>"


//图文混排
Html.ImageGetter imageGetter = new Html.ImageGetter() {
    @Override
    public Drawable getDrawable(String s) {
        Drawable drawable = null;

        Logger.t(TAG).d(s);
        int width = ViewGroup.LayoutParams.WRAP_CONTENT;
        int height = ViewGroup.LayoutParams.WRAP_CONTENT;
        ImageView view = new ImageView(WineInfoDetailActivity.this);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(width,height);
        view.setLayoutParams(params);

        ImageLoader.getInstance().displayImage(s,view);
        drawable = view.getDrawable();

        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        return drawable;
    }
};
//使HTML中的超链接起作用
tv_detailContent.setMovementMethod(LinkMovementMethod.getInstance());
tv_detailContent.setText(Html.fromHtml(consultInfo.getContent(),imageGetter,null));
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值