一个文本框2种字体大小、颜色

第一种方法:

        //设置两种字体大小
        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出价 %.0f元", item.getIsPerPrice() , item.getBidPrice())));

效果图:


你可能感兴趣的:(工具类集合,字体,文本框)