Supporting multiple screen size - android

I've used several images with different sizes. I copied the images into different folders.
such as (except drawable-ldpi folder):
for example :
drawable-mdpi test.png => 60*60 px
drawable-hdpi test.png => 85*85 px
drawable-xhdpi test.png => 110*110 px
drawable-xxhdpi test.png => 110*110 px
I have only one folder my layouts:
my manifest:
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
now, when I install my project on galaxy s4, images within the program shows drawable-mdpi folder. why ?
I even made ​​a separate folder for my layout and changed width and height of image :
res/layout/my_layout.xml imageview => layout_width and layout_height = 48*48 // default
res/layout-large/my_layout.xml
res/layout-xlarge/my_layout.xml
But always the default option is selected ! why?

you don't need to write support-screens in the minifest - default is fine.
first things first:
s4 is on the upper end of normal but it should still be normal not large. this is why your 'layout-large' was not used. but you should not use the size selection stuff, dpi selection is much better (so one layout should work).
s4 is on the edge between xxhdpi and xhdpi so samsung can decide what it is. i think they used xhdpi. but this should not realy matter.
dpi categories:
ldpi (you will not need it because neerly no device has it)
mdpi = 160dpi or 1x
hdpi = 240dpi or 1,5x
xhdpi = 320dpi or 2x
xxhdpi = 480dpi or 3x
simple dpi example:
if you have a fullscreen design/image in full hd (1080x1920) you can just cut the stuff out as you need it and will get it correct for xxhdpi. (if i remember correct - maybe xhdpi)
however, you can calculate the lower sizes from this point.
- xxhdpi = 1080x1920
- xhdpi = 720x1280 (/3*2 of the above)
- ...
if you do it this way it should work correct ;)

Related

Android values folder for Nexus 6

My problem:
I'm developing an android application and I'm having trouble with the layout on nexus 6 phones.
I don't know which values folder would be applicable to best match nexus 6.
Details about Nexus 6:
density - 560 dpi
Screen display - resolution of 2560 x 1440 (493 ppi).
What I have tried:
Nexus 6 and Nexus 9 Screen density
http://android-developers.blogspot.in/2014/10/getting-your-apps-ready-for-nexus-6-and.html
My res-values structure:
values-small (0.75)
values (1.0)
values-large (1.5)
values-xlarge (2.0)
I am also try the following dimens values.
values-xxxhdpi(3.0)
values-xxlarge(3.0)
values-xxxlarge(3.0)
My AndroidManifest.xml
<supports-screens
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"
android:resizeable="true"/>
But always picks the default dimens values(1.0)..
Any body solve my problem..Thanks..
The values folders are usually qualified on basis of smallest width (sw360dp) or width(w360dp) instead of screen density (mdpi, hdpi etc) to maintain density independence.
For example, folders as:
values-sw320dp
values-sw360dp
values-sw600dp
This is because by giving dimensions in dp, it would automatically resize in form of pixels on different screen densities.
With following convert ratios:
mdpi - 1
hdpi - 1.5
xhdpi - 2
xxhdpi - 3
xxxhdpi - 4
Screen density qualifier is preferred with drawable folders, as the image files are in pixels.
Nexus 6 has smallest width 360dp (configuration 360dp * 640dp) and xxxhdpi screen density.
You can try using folder values-sw360dp for Nexus6.
In Android Studio, nexus 6, 5x and 6p, all three devices use dimensions from values-sw400dp folder.
I think you are using both the structure in your application which will make a confusion.
So if you are using values-mdpi, values-hdpi, values-xhdpi, values-xxhdpi , values-xxxhdpi then go with that.
For Nexus-6, you have to use xxxhdpi.
Please remove values-small,values-large,values-xlarge,values-xxlarge.
Supporting all screens In this page, check the table 1 for understanding about screen characteristic.
Hope it will help you.

Android 2.2 - screen resolutions and sizes issue

The android version is 2.2. And the apps will not support drawable-xhdpi with drawable-xlarge folder. However, i have met many issue when I am processing different screen size from different mobile.
The first problem is that I want to know what is the situation that android will load correct image from drawable-ldpi, drawable-mdpi, drawable-hdpi folder? There are one image in each folder (drawable-ldpi, drawable-mdpi, drawable-hdpi).
(1) 240px x 150px for drawable-ldpi
(2) 320px x 200px for drawable-mdpi
(3) 480px x 300px for drawable-hdpi
But why i cannot see correct image if the output device width screen is 480px? The output device only shown 320px width image. Not the 480px image. The issue seems that what the thing i have missing?
Then, i renamed all drawable folder to drawable-small, drawable-normal, drawable-large. It is working that drawable-large can display 480px width image. Will it be good if i do this way?
The second issue is that some samsung device have got different screen resolutions, i would like to know how to support these screen resolution as I want to make 800px width screen displays 800px width image, 900px width screen displays 900px width image? Any method can do different screen resolution? Many people said the folder drawable-xhdpi can solve issue that image can be auto-scaling. I cannot see any image can be auto-scaling. Maybe i have missing some steps.
Kindly advise.
Thanks a lot.
I will try to give you better insight into this.
Screens can be divided into more or less 4 different categories:
Low-density
medium-density (Baseline)
high-density
extra-high-density
You also get xxhdpi these days...
low-density = ldpi (120dpi)
medium-density = mdpi (160dpi)
high-density = hdpi (240dpi)
extra-high-density = xhdpi (320dpi)
Another good example comes from the android developer pages:
http://developer.android.com/images/screens_support/screens-ranges.png
You can find a list of devices and their pixel densities here:
h ttp://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
h ttp://checkscreensize.appspot.com/listdevice.jsp
You will always be designing apps with multiple layouts/drawables to support different devices. Not just Samsung devices, but most brands have different devices with different pixel densities and resolutions.
In short, by providing multiple resources, android will choose the correct one to best fit the current device and if it does not find one in a certain layout or drawable folder, it will simply use the next best layout/resource with that name.
Note, this is to avoid stretching and incorrect scaling of drawables and layouts.
How to support multiple layouts ?
in your manifest file.
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Provide different layouts or drawables for different screen sizes.
Now, there are multiple ways of doing this and some ways are dependent on the sdk level.
Pre Android 3.2 / API 13 , use layout-small/normal/large/xlarge.
After Android 3.2 / API 13 , use layout-hdpi, or layout-sw600dp etc.
Here is the official table of qualifiers you can use, by placing a dash between them:
http://developer.android.com/guide/practices/screens_support.html#qualifiers
Generally, I think that you will only design for landscape mode with tablets, therefore, you could consider using only these and:
layout-ldpi
layout-mdpi
layout-hdpi
layout-xhdpi
layout-large
layout-large-land
layout-xlarge
layout-xlarge-land
and for your drawables:
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
Further, by default, I currently choose to design for 6 different devices that overall fits best in the profiles ldpi, mdpi, hdpi, xhdpi for phones (4) and tablets (2):
Samsung Galaxy S3 (720x1280, xhdpi, Normal screen size)
Samsung Galaxy S2 (480x800, hdpi, Normal screen size)
Samsung Galaxy Ace Plus (320x480, mdpi, Normal screen size)
Samsung Galaxy Mini (240x320, ldpi, Normal screen size)
Samsung Galaxy Tab 10.1 (800x1280, mdpi, X-Large screen size)
Samsung Galaxy Tab 7.0 (600x1024, hdpi, Large screen size)
Designing for these devices ensures that the app will work great on most other devices aswell.
Hope this information helped.

Android interface implementation for multiple screen sizes and densities

I'm developing an application and i need it to fit all screen sizes and densities.
I created 4 folders for the resources (drawable-ldpi,drawable-mdpi,drawable-hdpi,drawable-xhdpi) and 4 xml layouts. But i'm confused a little about many points:
1- If I have a Samsung Galaxy tab 10.1 (mdpi screen) with a 1280 x 800 screen size and a Samsung Gio (mdpi screen) with a 320 x 480 screen size, how can I make the "layout-mdpi" folder including the xml layout file for medium dpi, fits these 2 devices having the same dpi but 2 different screen sizes (Galaxy tab is much bigger than Samsung Gio)?
2- I'm creating my png's using Photoshop, these png's must be saved with 320dpi,160dpi,240dpi..? Or all the resources must be saved in 72 dpi but different sizes?
3- I tested a star icon on my Samsung Galaxy tab 10.1 (mdpi screen) having 32x32px size, dunno why my icon is blurred!
You have to make all 4 different sizes images and put that images according to folder.And also set the property in menifest like this.
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />

support different screen sized

I have a project for an application that can run on different types of android device:
-small device :example samsung ace
-normal device:samsung galaxi s3
-tablet 10''
My layout is complex and the use of match_parent and "dp" isn't enough. I have read: http://developer.android.com/guide/practices/screens_support.html but I did not understand all of it.
Will I have to create more XML's in say, res/layout-sw720dp/main_activity.xml folder ow will I have to use different qualifiers? How exactly does it work?
For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
The following code in the Manifest supports all dpis.
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Kindly Use This qualifier for your Android Project with compatible screen size.
Resource Screen Size
layout-small <3 inch
layout-normal 3-4 inch
layout-large >4 inch<7.1
layout-xlarge 7.1 - 10.1 inch
If you still facing problem use this Tutorial Link
If you want to create 1 application for different devices then you have to use android different folder as defined in the sdk
for e.g
drawable-ldpi - to place the images for the low screen density devices(240*320)
drawable-mdpi - to place the images for the middle screen density devices(320*480)
drawable-hdpi - to place the images for the high screen density devices(480*800)
drawable-xhdpi - to place the images for the extra high screen density devices (above 480*800)
If you want to create application for the tablet
drawble-sw720dp - to place the images for the tablet devices(7")
drawable used to place images. you have to create the layout for different drawable folder
layout-ldpi - to place the layout for the low screen density devices(240*320)
layout-mdpi - to place the layout for the middle screen density devices(320*480)
layout-hdpi - to place the layout for the high screen density devices(480*800)
layout-xhdpi - to place the layout for the extra high screen density devices (above 480*800)
android automatically get the images and layout from the application according to the device density. but for this you have to define
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
so that application develop for the multiple screen resolution devices.
To develop an application which supports every density and resolution, we should keep following points in mind:
(1) Put different sized images(with the same name) in 4 different folders in the ratio:
ldpi : mdpi : hdpi : xhdpi = 3 : 4 : 6 : 8
(2) The sizes commonly used for these resolutions are:
ldpi = 36 * 36 px mdpi = 48 * 48 px hdpi = 72 * 72 px xhdpi = 96 * 96 px
But you can use your desired sizes for the images as well.(Just try to follow the ratio in different sizes as well.) Amongst of all these images, the image which suits the device's density , will automatically be picked.
(3) Besides this, you can also get the density of the device programmatically and set the layout accordingly, like this:
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
switch(displayMetrics.densityDpi){
case DisplayMetrics.DENSITY_LOW:
// layout for small sized devices.
break;
case DisplayMetrics.DENSITY_MEDIUM:
// layout for medium-sized devices.
break;
case DisplayMetrics.DENSITY_HIGH:
// layout for big-sized devices.
break;
}

mdpi and hdpi images are not correctly loaded into the device android

i have images accordingly int the hdpi and mdpi folder but when i run the application the hdpi images are loading fine on the high resolution devices but when i run on medium resolution 320 x 480 the hdpi images are loading not the medium ones. i have also tested moving the images to res/drawble but nothing happens.. please help me on this
i have set the manifest file with
<supports-screens android:smallScreens="false" android:normalScreens="true"
android:largeScreens="true" android:anyDensity="true">
<uses-sdk android:minSdkVersion="8" />
Please check if your drawable folders are correctly named.
They should be:
drawable-mdpi
drawable-hdpi
Also, be sure that your file names are identical. It works fine for me.
Sometimes it may even work to clean the project using Eclipse.
EDIT:
I think your project is working fine, but you're making some mistakes with your setup. You probably haven't read the developer guide properly: http://developer.android.com/guide/practices/screens_support.html
Anyway, what you're essentially doing is saying that mdpi = 320 x 480 and hdpi = 480 x 800 pixels. But that's not correct. The DPI (dots per inch) has nothing to do with the actual resolution of the screen. You can easily have a medium DPI screen with a resolution larger than 320 x 480 pixels.
Read the link that I posted - especially the part called "How to Test Your Application on Multiple Screens". That should help you.

Categories

Resources