Home > Web Front-end > HTML Tutorial > 富文本Html.fromHtml方法_html/css_WEB-ITnose

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

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

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

这是Textview使用富文本


Toast和富文本结合使用,

    Toast toast2 = Toast.makeText(getApplicationContext(), "这是个提示", Toast.LENGTH_SHORT);<br>toast2.show();<br>toast2.setGravity(Gravity.LEFT|Gravity.CENTER, 100, 0);<br>Spanned spanned = Html.fromHtml("我是<img  src="" alt="富文本Html.fromHtml方法_html/css_WEB-ITnose" >一个<font color="#55ff0000">富文本</font>", new Html.ImageGetter() {<br>//添加图片<br>    @Override<br>    public Drawable getDrawable(String arg0) {//返回一张图片,但是必须设置图片大小<br>        Drawable drawable = getResources().getDrawable(R.mipmap.apple);<br>        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());<br>        return drawable;<br>    }<br>}, null);<br>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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template