String attention = getResources().getString(R.string.facebook_attention);//待修改字符串(例如关键字是5000)
String i=5000;
TextView tvAttention = (TextView) view.findViewById(R.id.tv_pay_attention);
SpannableStringBuilder ssbuilder = new SpannableStringBuilder(attention);
ForegroundColorSpan yellowSpan = new ForegroundColorSpan(getResources().getColor(R.color.yellow_fa));//修改关键字的字体颜色
ssbuilder.setSpan(yellowSpan, attention.indexOf(i), i.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tvAttention.setText(ssbuilder);
TextView 关键字颜色 样式修改
最新推荐文章于 2022-04-25 14:35:34 发布