第一种方法:
//设置两种字体大小 Spannable WordtoSpan = new SpannableString(codeMemoTV.getText().toString()); WordtoSpan.setSpan(new AbsoluteSizeSpan((int) DimensionUtil.convertDpToPixel(18, this)), 0, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); codeMemoTV.setText(WordtoSpan); //设置两种字体颜色和大小 Spannable WordtoSpan1 = new SpannableString("好友成交额6255.50元"); WordtoSpan1.setSpan(new AbsoluteSizeSpan((int) DimensionUtil.convertDpToPixel(18, this)), 5, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); WordtoSpan1.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.black)), 5, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); codeMemoTV.setText(WordtoSpan1);
msgTV.setText(Html.fromHtml(String.format("%s出价 <font color=\"#f06c55\">%.0f</font>元", item.getIsPerPrice() , item.getBidPrice())));
原文地址:http://blog.csdn.net/pengkv/article/details/45716233