android小技巧之TextView设置不同字体大小及样式

1. 设置不同大小

先看效果
![](https://img-blog.csdn.net/20160305120047030)

附上代码

java

tvText = (TextView) findViewById(R.id.tv_text);
String text = “这是大文字,这是小文字”;
int start = text.indexOf(‘,’);
int end = text.length();
SpannableString textSpan = new SpannableString (text);
textSpan.setSpan(new AbsoluteSizeSpan(50),0,start,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
textSpan.setSpan(new AbsoluteSizeSpan(32),start,end,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
tvText.setText(textSpan);

你可能感兴趣的:(Android小技巧)