7

I am wondering how can I create or use if exists feature of TextView, to automatically change it's font size to fit the place.

Sometimes it should be larger if has space, and sometimes it should shrink in font size to fit the space.

What do you say?

Pentium10
  • 204,586
  • 122
  • 423
  • 502

1 Answers1

2

you can change the font in your overrided version of

protected void onSizeChanged (int w, int h, int oldw, int oldh)

method.You need just to subclass TextView to do it.

Also, check this.

Community
  • 1
  • 1
Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103
  • How do I know if I should change the size? – Pentium10 Dec 16 '10 at 15:08
  • you should have some measurement: dip per character. create a label with fixed width in dip, chech how much characters fits in it. Dividing one by another, you will get your font size. In onSizeChanged check the widht for you text. – Vladimir Ivanov Dec 16 '10 at 15:24
  • Also, it is a bad practise to down vote the answer if you don't just understand some details. Just request the clarification. – Vladimir Ivanov Dec 16 '10 at 15:24