android textView 技巧 富文本显示 代码设置selector

一、富文本显示

1、用xml实现 

ex:

appToast.setText(Html.fromHtml(“共<font color=yellow>”+ size()+ “</font>个软件,有<font color=yellow>”+Update + “</font>有更新”));


ex:

String parenName =entity.getParent().getMember_nickname();

parantNameRich =“<font color=’#ff82ab’>” +parenName +“</font>” ;

holder.parentETV.setText(Html.fromHtml(parantNameRich+“: “ +parenString));


注: html的解释 是全部一起来的  parantNameRich“: “ + parenString



2、用 SpannableString  实现

ex:

TextView tv= (TextView) findViewById(R.id.tv);

SpannableString sp = new SpannableString(“输入物件名称,例如 “某某””选择SG””);

// 设置样式一
sp.setSpan(new ForegroundColorSpan(0xff009eff)

来源:14

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2014年8月18日
下一篇 2014年8月19日

相关推荐