i am working on an android app. as this should be all screen size supportive .but it is not working properly.
I can I set that for 480*800 size it will take images from drawable-hdpi folder?
Screen size and dpi aren't the same thing. DPI is the number of pixels per inch. a 480x800 screen can still be any dpi level- it would just be a smaller screen with higher dpi.
You can try doing a size override with drawable-swNdp where N is a pixel value. That works for layouts, I believe it also works for drawables.
To support on all resolution devices put different resolutions images in different folders in drawable as,
drawable-ldpi - 240 * 380
drawable-mdpi - 320 * 480
drawable-hdpi - 480 * 800
drawable-xhdpi - 720 * 960
For more info about resolution refer this link :
http://developer.android.com/guide/practices/screens_support.html
Related
For example, I'd like to show an image in screen. Here are the size and dpi:
LDPI - 0.75x 75x75 120 dpi
MDPI - Original size 100x100 160 dpi
HDPI - 1.5x 150x150 240 dpi
XHDPI - 2.0x 200x200 320 dpi
XXHDPI - 3x 300x300 480 dpi
XXXHDPI - 4.0x 400x400 640 dpi
But the display for two devices is not what I want.
The first device is 480x800, 240 dpi. The second device is 800x1280, 213 dpi.The bigger screen has lower dpi. I need some advices on how to handle this case? Thanks
What I see is that your first device is a mobile while the second is a tablet. So you can provide alternate layout files for mobile's and tablets. See supporting multiple screens for more information. For this case for mobile you can use layout-sw720dp folder and for the bigger tablet screen. As for the images your current settings above will work great.
I am working on Android application that should support 2.1 till latest Android OS (4.2) version. Currently I have few images to display in my image-gallery module.
I need to support my app on all devices (smartphone and tablet) which support OS ranging from 2.1 to 4.2 (latest).
Each image is roughly of size 368X387, 50 KB each, PNG type
My workspace res contains following drawable folders:
drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xdpi
I have some confusion around
In which folder should I store the images, and how will that matter?
Do I need to have different resolution based images for different type of devices?
Thanks.
You can store images only in 1 folder BUT,
for example you have device that is mdpi.. it will look good on him, but if you run your app on ldpi android will automatically scale your image and it will look ugly (low quality). So yea you need different resolution based images for different types of devices..
so mdpi resolution images go to drawable-mdpi
so hdpi resolution images go to drawable-hdpi etcc..
this is some list i found on internet about screen sizes, maybe you will find it helpful:
Low density Small screens QVGA 240x320 (120dpi):
layout-small-ldpi (240x320)
layout-small-land-ldpi (320x240)
Low density Normal screens WVGA400 240x400 (x432) (120dpi):
layout-ldpi (240 x 400 )
layout-land-ldpi (400 x 240 )
Medium density Normal screens HVGA 320x480 (160dpi):
layout-mdpi (320 x 480 )
layout-land-mdpi (480 x 320 )
Medium density Large screens HVGA 320x480 (160dpi):
layout-large-mdpi (320 x 480 )
layout-large-land-mdpi (480 x 320)
Galaxy Tab ( 240 dpi ):
layout-large (600 x 1024)
layout-large-land (1024 x 600)
High density Normal screens WVGA800 480x800 (x854) (240 dpi):
layout-hdpi (480 x 800)
layout-land-hdpi (800 x 480)
Xoom (medium density large but 1280x800 res) (160 dpi):
layout-xlarge (800 x 1280)
layout-xlarge-land (1280 x 800)
Also it would be good to read official documents site about supporting different types of screen.
There are four folder in resource folder 1- drawable-hdpi 2-drawable-ldpi 3-drawable-mdpi
4-drawable-xdpi
To declare different layouts and bitmaps you'd like to use for different screens, you must place these alternative resources in separate directories/folders. This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.
Then, place the files in the appropriate drawable resource directory: as per your need
if you want to use same images for all types of screen then you can make an other folder named "drawable" and put all images in that folder. it would work as default drawable.
but if you want to improve image quality on all resolutions. then you need all 4 types images and put then on their respective folder with same image name. you can also make differ XMLs for each resolution.
See this http://developer.android.com/training/multiscreen/screendensities.html
You can put a particular image in all folders.
drawable-hdpi
---->img.png
drawable-ldpi
---->img.png
drawable-mdpi
---->img.png
drawable-xdpi
---->img.png
It all depends on your os .it ll take by default according to device resolution .
In android we have "Res" folder is nothing but resources folder.Inside this res folder we have other sub folders but for storing images we have four types of folders names are called:
drawable-hdpi
for High density screens and its resolutions is 480*800
drawable-ldpi
for Low density screens and its resolutions is 240*320
drawable-mdpi
for Medium density screens and its resolutions is 320*480
drawable-xdpi
for Xtra density density screens and its resolutions is 640*960
If you want to match image for multiple screens my suggestion is to use
Nine patch image rather than .png and .bmp
for creating nine patch image
http://developer.android.com/tools/help/draw9patch.html
I am developing an app which must support Samsung Galaxy Note - 2.
Now note-2's pixel resolution is 1,280 x 720. Reference Wikipedia.
While developing an app, I found that it was picking images from res/drawable-hdpi.
So for what resolution layout I should prepare the images ? Or do need to make separate resource folder ?
Resources are picked based on DPI a quick reference for what DPI each device uses can be found here:
http://blog.blundell-apps.com/list-of-android-devices-with-pixel-density-buckets/
For image scaling, the images should roughly be sized like so:
if an image is to use 100 dp then the actual images sizes will be:
ldpi: 75px
mdpi: 100px
hdpi: 150px
xhdpi: 200px
if you want to use 100 px on your NOTE 2 then the image sizes will be
ldpi: 50px
mdpi: 66.67px
hdpi: 100px
xhdpi: 133.33px
you can use the following site do do quick calculations:
http://labs.skinkers.com/content/android_dp_px_calculator/
Prepare images for hdpi resolution -- 480x800 hdpi.
Galaxy Note 2 is normal size, xhdpi density and long. You can prepare layout or drawable for xhdpi. For details, please check this post Galaxy Note 2 screen specifications. If you don't have xhdpi resource, android will try to find resource in hdpi.
The Galaxy Note uses hdpi which is a pixel density of 240dpi
Android Device Resolutions
I have 4 sets of images
Resolutions DPI Directory
240 x 320 120dpi - drawable-ldpi
320 x 480 160dpi - drawable-mdpi
480 x 800 240dpi - drawable-hdpi
1280x 800 320dpi - drawable-xhdpi
But when I tested it at ASUS transformer with resolution 1280x800 and DPI 224.
It loaded graphics from drawable-hdpi.
If I will add another folder with name drawable-xlarge, It will load desired images but it will increase the size of application as well.
My questions are as follows
1 - What is the best practice to support all screen sizes and DPI?
2 - Is there any way to force load drawable of particular DPI w.r.t screen size?
3 - What is the solution recommended for my problem without replicating the graphics?
But when I tested it at ASUS transformer with resolution 1280x800 and dpi 224. It loaded graphics from drawable-hdpi.
That is because the ASUS Transformer is an -hdpi device. Hence, it is working properly.
What is the best practice to support all screen sizes and dpi?
Usually, images only vary based on density, and so your current structure is fine.
If you elect to have images that vary both on screen size and density, you will need to make more directories (e.g., res/drawable-xlarge-hdpi/) and images for the
Is there any way to force load drawable of perticular dpi w.r.t screen size?
Density and screen size have nothing to do with one another.
What is the solution recommended for my problem without replicating the graphics?
According to your "question", you do not have a problem. Hence, there is no recommendation for your non-problem.
Well, I set my AVD to
480 x 800 resolution ,
abstracted lcd density to 320 pixel
And my image dimension is 207 width and 205 height and the image has set to 320 pixels per inch but it is shown very big on avd with resolution 480 x 800 and 320 dpi. Images are placed in #drawable/MDPI folder only. Here it is
Does image needs to set on 160 pixels per inch or I have to set avd size using (scale display to real size) option?
You have emulator of 320 dpi which is xhdpi. And you are putting your images in mdpi folder. Now when you launch your app it looks for images in xhdpi folder first and it finally load images from mdpi folder scale them to xhdpi density and show them. Thats why images are coming big.
May be you can test in mdpi density emulator or you can support xhdpi in your app by having images in xhdpi.
check with android:src="" and android:background="" attribute in xml file in the ImageView.