2

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

RAAAAM
  • 3,346
  • 18
  • 58
  • 107

3 Answers3

1

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

RAAAAM
  • 3,346
  • 18
  • 58
  • 107
0

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

Chintan Rathod
  • 25,332
  • 13
  • 78
  • 92
0

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

Community
  • 1
  • 1
Raegon
  • 61
  • 5