Wednesday 7 April 2010

Motorola Droid small fonts

Writing Android applications for some time I needed to use text messages. TextView, for example. And I was happy using "pt" units for font size. Somehow it looked as expected. However, update to 2.1 API was released and those messages get very small on Motorola Droid phone, which was a surprise for me. On the emulator everything worked like before.

Investigating that issue I found out that the sizes in "pt" units are treated as sizes in "px" units, which are pixels. However, some of layouts remained unchanged. Those layouts were created by a guy, who reads manuals before writing code. So, as you may expect, he used "sp" (scaled pixels) units, which worked perfectly. And I had to change all my weird units to the documented "sp". Unfortunately, specifying size in "sp" units produce smaller letters than "pt", so I had to play with the numbers to get the desired result.

P.S.
I tried to change font size with Spare Parts application. Unfortunately, it doesn't work well. On the emulator it changes fonts for current Activity, which is Spare Parts itself (or its part). But when I navigate to the home screen and get back, the font remains the same (Normal). On the Droid it's the same.

P.P.S.
Read manuals. :)