문제

Is it possible to set different TextSize for different parts of the content of a given Textview using XML in android ?

도움이 되었습니까?

해결책 2

No, it is not possible from the XML, but you can do it in JAVA.

Check out this and this.

다른 팁

Programatically but not using XML you could achieve it using setSpan

For 10 Characters word with first 5 chars has fontsize 12 and last 5 chars has 16.

 Textview myTextView = (TextView)findViewById(R.id.textview); SpannableString
 text = new SpannableString(myString);

 text.setSpan(new TextAppearanceSpan(null, 0, 12, null, null),0,5,
 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 

 text.setSpan(new TextAppearanceSpan(null, 0, 16, null, null),6,10,
 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

 myTextView.setText(text, TextView.BufferType.SPANNABLE);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top