Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView with different textSize

Is this possible to set different textSize in one TextView? I know that I can change text style using:

TextView textView = (TextView) findViewById(R.id.textView); Spannable span = new SpannableString(textView.getText()); span.setSpan(arg0, 1, 10, arg3); textView.setText(span) 

I know the range start...end of text I want to change size. But what can I use as arg0 and arg3?

like image 299
woyaru Avatar asked Sep 12 '11 13:09

woyaru


People also ask

Which method is used to change the Textsize of the TextView?

Default setting lets the autosizing of TextView scale uniformly on horizontal and vertical axes. To define the default setting programmatically, call the setAutoSizeTextTypeWithDefaults(int autoSizeTextType) method.

Can we change the text in TextView?

TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);

How do I make a TextView look like a link?

This is the shortest solution: final CharSequence text = tv. getText(); final SpannableString spannableString = new SpannableString( text ); spannableString. setSpan(new URLSpan(""), 0, spannableString.


1 Answers

Try

span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 
like image 140
Michele Avatar answered Oct 05 '22 18:10

Michele