第一种方法:
//设置两种字体大小 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())));
效果图:
时间: 2024-09-29 23:11:22