- SpannableString style = new SpannableString("你好啊 哈哈哈哈哈哈哈哈哈哈哈哈");
- style .setSpan(new TextAppearanceSpan(this, R.style.style1), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- style .setSpan(new TextAppearanceSpan(this, R.style.style2), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- mTextView.setText(style , TextView.BufferType.SPANNABLE);
- <style name="style1">
- <item name="android:textSize">24dp</item>
- </style>
- <style name="style2">
- <item name="android:textColor">#ff0000</item>
- </style>