Edited Question:
Mobile Resolution:
I would like to design different screen dpi like following resolutions.
320x480,
480×800,
540x960,
720x1280 (Samsung S3),
1080x1920 (S4, Nexus5,Nexus 5x, Moto G4),
2560 x 1440 (Nexus 6, Nexus 6p, Samsung edge)
Tablet Resolution:
480x800 (micromax) ,
600x1024 (samsung tab2),
800x1280 (nexus 7),
1200x1920 (new nexus 7),
2048x1536 (nexus 9)
I want to use different font sizes depending on the device display resolution.
Q1) What is the best
way to solve this problem
?
Q2) What is best option doing throw coding or XML?
Q3) Which drawable folder is represent which device resolution?
Q4) Application Launcher icon size for different resolution?
First your application design for one resolution .
example : suppose your mobile resolution 380*480
find screen size programmatically using belove formula
For nexus 6 device support , create drawable-560dpi folder and put all images in it.
I think this is a good answer:
Text size and different android screen sizes
But here how you can do it with screen resolution :
You can create "values" resource directory for each resolution like
In each dir (including default values dir) create a file named "dimens.xml" with content:
Now you can use the "@dimen/def_font_size" or create a style in the default values directory.
Add this to the "styles.xml":
App launcher icon size in pixels for different resolution
Mobile Resolution
Tablet Layouts:
Use following folders if you wish to have tablet-specific layouts:
Drawables folders:
Mobile
Tablet Resolution:
Font Sizes:
Use predefined
textAppearance
:It will set text size automatically as per device density.
Sample usage:
Use
dimension.xml
for each device:From Google IO Pdf, we see structure below:
Mobile:
Tablet:
For tablet you can use more specific folder like
values-xlarge
,values-large
.or
Excerpt from Supporting Multiple Screens:
I have created a function which convert size of dp to the size according to screen size and it is working well for me. Any one having problem with text size according to screen should give this a try.
simple give the value given by it to the text view size programically as below
First you create the different values folders for different screens.and put the size according to the screens in
res->values->dimens.xml
file and call the simple font size using"@dimen/text_size"
.and retrieve the font size in
TextView
as given below.