Am trying to write generic code for all the resolutions. Being a new developer am getting stopped by this font issue. Consider am having various resolutions ( 100 * 100, 200 * 200, 300 * 300 etc ).Am having a textview if suppose i set the font size as 20 for 100*100, when i am porting this code to 200*200, the size of the font seems to be very small for the resolution 200*200. Could any plz tell how to calculate font size for various regions. Is there any formual available to calculate it.. plz advise.. thanks in advance...
Asked
Active
Viewed 8,206 times
1
-
just set the textsize in dip and it will maange itself according to screen resolution – ingsaurabh Feb 15 '11 at 13:14
-
1have to say that I'm not an Android developer, but: If you use some values for different resolutions, you can multiply your font size by the number you set. For instance value=1 for the resolution 100, value=1.4 for the resolution 200, value=1,6 for 300, etc. And when you set the font size you should multiply it by the value. – fsonmezay Feb 15 '11 at 13:17
1 Answers
6
Try using sp
unit for your font size.
sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.
More information here
Take sometime reading this to understand the different measurement units used in Andriod as well.