RAAAAM
RAAAAM

Reputation: 3380

Dynamically change Textview size

Is it possible to change the single textView size dynamically? In the below link the text size is dynamically changed. ? can anyone guide me on how to do this. thanks in advance Dynamic text size

Upvotes: 2

Views: 662

Answers (3)

RAAAAM
RAAAAM

Reputation: 3380

Thanks for all, at-last i used three different textview to design whatever i need. Thanks for all.

Upvotes: 1

Chintan Rathod
Chintan Rathod

Reputation: 26034

Try following code

span.setSpan(new RelativeSizeSpan(0.8f), start, end,
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

Here, you need to set start and end as per your requirement. 0.8f is size of text here. You need to pass float value here.

Code

textView = (TextView) findViewById(R.id.textView);
Spannable span = new SpannableString(textView.getText());
span.setSpan(new RelativeSizeSpan(0.8f), 0, 7,
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
span.setSpan(new RelativeSizeSpan(1.8f), 7,
            txt.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
txt.setText(span);

Output

enter image description here

Upvotes: 0

Raegon
Raegon

Reputation: 61

Yes. You can use SpannableStringBuilder to styling the text. Same question is registered at here

Upvotes: 0

Related Questions