富文本Html.fromHtml方法_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:37:47
Original
1681 people have browsed it

用于对选中的部分进行格式更改,或者添加图片

这是Textview使用富文本


Toast和富文本结合使用,

Toast toast2 = Toast.makeText(getApplicationContext(), "这是个提示", Toast.LENGTH_SHORT);
toast2.show();
toast2.setGravity(Gravity.LEFT|Gravity.CENTER, 100, 0);
Spanned spanned = Html.fromHtml("我是富文本Html.fromHtml方法_html/css_WEB-ITnose一个富文本", new Html.ImageGetter() {
//添加图片
@Override
public Drawable getDrawable(String arg0) {//返回一张图片,但是必须设置图片大小
Drawable drawable = getResources().getDrawable(R.mipmap.apple);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
return drawable;
}
}, null);
toast2.setText(spanned);//重新设置文本
Copy after login

版权声明:本文为博主原创文章,未经博主允许不得转载。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!