Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different font sizes for different screen sizes

Tags:

In my application I must use a smaller font for the medium density devices. Is it possible to specify that?

like image 590
Gratzi Avatar asked Jan 17 '11 13:01

Gratzi


People also ask

How do I change the font size on different screens?

To change your display in Windows, select Start > Settings > Accessibility > Text size. To make only the text on your screen larger, adjust the slider next to Text size. To make everything larger, including images and apps, select Display , and then choose an option from the drop-down menu next to Scale.

How many different font sizes should I use?

1. Keep The Number of Fonts Used At a Minimum. Using more than 3 different fonts makes a website look unstructured and unprofessional. Keep in mind that too many type sizes and styles at once can also wreck any layout.

Do different fonts have different sizes?

In digital fonts, the size of any given font at a specific point size can vary from font to font. That is, fonts at the same point size can have different x-heights and sometimes varying cap heights.

When sizing fonts for a webpage what two measurements work best?

The font size on a website should be responsive to the screen size that displays it. In general, a font should be 12-16pt on a mobile screen, 15-19pt on a tablet, and 16-20pt on a desktop computer screen.


2 Answers

You should use styles, then you can have separate folders "values" (default) "values-hdpi" (high density) "values-mdpi" (medium density) and so on and put your style file with correct textSize values in each folder as needed.

Then, when you are in medium density device it will pick the file in "values-mdpi" folder if exists or in "values" if not, and the same for high density etc...

This same principle applies to al "res" subfolders (drawables, values, etc...)

like image 77
maid450 Avatar answered Sep 22 '22 07:09

maid450


Specify all your fonts using dips (e.g. 14dp) rather than pixels (e.g. 14px) and you won't need to worry about screen density. Android will scale your fonts (and layout) accordingly.

Edit: Here's comparison of sp/dp from the Android docs:

dp Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, so 160dp is always one inch regardless of the screen density. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. You should use these units when specifying view dimensions in your layout, so the UI properly scales to render at the same actual size on different screens.

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 the user's preference.

like image 43
Dave Avatar answered Sep 20 '22 07:09

Dave