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>"));

 

posted @ 2015-01-27 18:58  狂奔的小狮子  阅读(744)  评论(0)    收藏  举报