I made an app earlier which was all good, at the time of development there were only two devices in the market galaxy note and samsung nexus, now devices with resolution 720*1280 are around 30, when my app runs on these devices they go to left corner leaving the empty space behind, layout folder name were created were layout-small, layout-large, layout-normal,
As far I know xlarge is for tablets, my question is what will be the layout folder name for devices having 720*1280 resolution, and what dpi in width they have, like in normal screen the width is 320dp , what will be in hd devices.
Edit : another thing sw360dp works fine on ICS, jelly beans does not pick resources from it. :/
Try using folder name with /layout-sw360dp/ and width 360dp
For devices having 720 * 1280 resolution, you can use layout-sw720dp folder
More info is provided in the official documentation (see Configuration Examples)
To help you target some of your designs for different types of
devices, here are some numbers for typical screen widths:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
For other cases in which you want to further customize your UI to
differentiate between sizes such as 7” and 10” tablets, you can define
additional smallest width layouts:
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
Related
So I have two phones Note 3 (5.7in 1080p) here is a screenshot of the app:
And I also have A7 2018 (6in 1080x2220 18.5:9) here is a screenshot:
After seeing the massive difference how can I make stable UI across multi-screen sizes and resolutions, and what makes the situation even worse is Android Studio's preview lack of precision.
like is there any way to create something like separate XML layouts for separate classes of display?
This link from the official docs will help you.
Things you can do to support different screen sizes are:
Avoiding usage of absolute values
If you use absolute values, use dp for sizes and sp for font sizes
Use match_parent or wrap_content whenever possible
If you use a ConstraintLayout Guidelines will probably be your friend (can create them % based)
If nothing of the above helps, create a seperate layout for a different screensize (explained here)
It's either use ConstraintLayout with GuideLines or use different layouts for different screen sizes.For example, you can create a layout named main_activity that's optimized for handsets and tablets by creating different versions of the file in directories as follows:
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
Here's how other smallest width values correspond to typical screen sizes:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a large phone screen ~5" (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
Check out the docs:
https://developer.android.com/guide/practices/screens_support#DeclaringTabletLayouts
Android documentation Use the Smallest-width Qualifier
states:
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc)
meaning that screen widths with 660dp and higher are tablets like. But a phone with lets say only 5.5 inches and 1440x2960 570dpi doesnt mean that it is a tablet.
So how can you distinguish that difference?
Thanks
But a phone with lets say only 5.5 inches and 1440x2960 570dpi doesnt mean that it is a tablet.
Correct.
So how can you distinguish that difference?
Use the smallest-width qualifier.
1440 pixels at 570 dpi = 2.53 inches = 404dp. 404dp is less than 600dp, and so your proposed device would not use -sw600dp resources.
Have declared next values folders.
values
values-sw320dp (... to 4'')
values-sw480dp (5'' to 5,5'')
values-sw600dp (7'' to 10'')
values-sw720dp (10'' to ...)
In each folder have one dimens.xml file with different margins, paddings, etc...
But don´t know what specific values folder need to work with display between 4'' and 5'', specifically 4,65'' and 4,7''.
Check the correct device resolution and follow the charts offered by Android:
http://developer.android.com/guide/practices/screens_support.html
Configuration examples:
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800
hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
in your case you will have your 4,65'' device in "values-480dp" folder.
I have
layout
layout-large
layout-xlarge
folders in my res folder.
But despite being a 7 inch tablet the layouts are picked from layout folder instead of layout-large.
and device runs on android 4.0
Am i missing something??
Thanks.
Check Configuration examples in Supporting Multiple screens document.
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
Check the correct device resolution and follow the charts offered by Android:
http://developer.android.com/guide/practices/screens_support.html
Configuration examples:
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800
hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
in your case you need to create a "layout-600dp" folder inside your "res" folder.
Because the DP of the device is 160dp/inch which falls under the category of mdpi devices
I created 4 different layout files and placed it in layout , layout-small,layout-large,layout-xlarge. folder and
TESTED IN QVGA,HVGA,AND WXGA EMULATOR.
But it is only taking the default layout(which i placed it in layout folder)for all emulator. Any solution?
Have you given the same name to all layout file, for e.g. main.xml, i mean to say give the same name to xml layout files and places in the particular folder. It will automatically managed by Android itself, programmer need not to bother about the same.
I made my comment as answer as this is right as per vnshetty's comment above. So that other answers may not be selected as accepted wrongly.
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
For other cases in which you want to further customize your UI to differentiate between sizes such as 7” and 10” tablets, you can define additional smallest width layouts:
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
http://developer.android.com/guide/topics/resources/providing-resources.html
layout-medium does not exist - should use layout-normal instead
Also are you specified min api version? it will works only if you specify <uses-sdk android:minSdkVersion="4" />
or higher in your manifest file.