一个TextView 设置两种字体颜色和大小

来源:互联网 发布:js settimeout无效 编辑:程序博客网 时间:2024/05/17 22:04
String currentIncome="100";
String s="\t元";String str=currentIncome+s;SpannableStringBuilder sp = new  SpannableStringBuilder(str);
 //字体颜色  
sp.setSpan(new ForegroundColorSpan(0xFFFF0000), name.length(), str.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
 //字体大小 
sp.setSpan(new AbsoluteSizeSpan(18, true), currentIncome.length(), str.length(), Spanned.SPAN_USER_SHIFT);
tv_current_comin.setText(sp);
0 0