工作,我知道SpannableString有可能在一個TextView中設置不同的文字大小,但如果添加的TextView編程它不工作。spannablestring不用於編程createed按鈕
String s = "Best Ever";
SpannableString ss1 = new SpannableString(s);
ss1.setSpan(new RelativeSizeSpan(2f), 0, 4, 0); // set size
ss1.setSpan(new ForegroundColorSpan(Color.RED), 0, 4, 0); // set color
TextView tv = (TextView) findViewById(R.id.textview);
tv.setText(ss1);
的API版本? 5+? – pskink
是的,它的5 @pskink – Venky
他們在v5中改變了它,http://stackoverflow.com/questions/29007746/button-settext-with-spannable-dosent-work-for-android-5-0-lollipop – pskink