TextView分段显示不同颜色,字体

String text = bt_addnewdev.getText().toString().trim();
		Spannable span = new SpannableString(text);
                //字号70,前4个字符
		span.setSpan(new AbsoluteSizeSpan(70), 0, 4,
				Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                //字体
                span.setSpan(new StyleSpan(Typeface.BOLD), 0, 4,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                //颜色
                span.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.orange)), nStart, nEnd,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		bt_addnewdev.setText(wordtoSpan);

你可能感兴趣的:(android)