Android之修改部分字体颜色
#01# 方法一:
TextView textView = (TextView) view.findViewById(R.id.text); SpannableString ss = new SpannableString("北京欢迎你,荣昌挺好的"); ss.setSpan(new ForegroundColorSpan(Color.RED), 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ss.setSpan(new ForegroundColorSpan(Color.GREEN), 7, 10, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(ss);
#02# 方法二:
textView.setText(Html.fromHtml("<font size=\"3\" color=\"red\">北京欢迎你,荣昌挺好的</font><font size=\"3\" color=\"green\">,挺好的</font>"));
时刻怀有一颗虔诚之心,乐于分享。知识才更有意义。

浙公网安备 33010602011771号