Android TextView显示html图片

阅读更多
html = "

this is h1

" + "This text is normal " + ""; charSequence = Html.fromHtml(html, imgGetter, null); infoContent.setText(charSequence);


ImageGetter imgGetter = new Html.ImageGetter() {  
        public Drawable getDrawable(String source) {  
            Log.i("RG", "source---?>>>" + source);  
            Drawable drawable = null;  
            URL url;  
            try {  
                url = new URL(source);  
                Log.i("RG", "url---?>>>" + url);  
                drawable = Drawable.createFromStream(url.openStream(), ""); // 获取网路图片  
            } catch (Exception e) {  
                e.printStackTrace();  
                return null;  
            }  
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),  
                    drawable.getIntrinsicHeight());  
            Log.i("RG", "url---?>>>" + url);  
            return drawable;  
        }  
    };

你可能感兴趣的:(android)