I have read many articles on "How to make a responsive app in android" everyone has suggested to use "multiple bitmaps" for each screen. I just want to know that
(1) Can we consider different drawable folders(drawable-hdpi,drawable-xdpi,drawable-xxdpi etc) in-supporting of tablets? or just these folders are designed for smart phones in order to get responsiveness?
In Android you have 2 type of qualifiers for image sizes:
Screen pixel density (dpi): Is the screen resolution. i.e. hdpi, xhdpi, tvdpi.
Screen size: Is the phisical size of the screen. i.e. small, normal, large, xlarge.
Some tablets have big screens, but with low dpi, there so they use images from mdpi or hdpi folder. But you can create special folders for tablets using the screen size qualifier to assign images. For example you can have:
res/
drawable-mdpi/
drawable-hdpi/
drawable-xhdpi/
drawable-xxhdpi/
drawable-xlarge-mdpi/
drawable-xlarge-hdpi/
drawable-xlarge-xhdpi/
drawable-xlarge-xxhdpi/
Your tablet will use the resources from drawable-xlarge- according to the dpi resolution.
To learn more about this refer to:
https://developer.android.com/guide/topics/resources/providing-resources.html
Responsive app is not just about using different Drawables. It contains Layouts and Dimensions too.
I advise you to read these two articles from google :
Designing for Multiple Screens
Supporting Multiple Screens
Related
This question already has answers here:
Android screen size HDPI, LDPI, MDPI [duplicate]
(4 answers)
Closed 9 years ago.
I have to manage different screen sizes and different densities in my Android app.
I am not getting directory structure properly.
What I understand so far is there are four types of screen sizes:
small
normal
large
xlarge
and different densities as well:
ldpi
mdpi
hdpi
xhdpi
Now each device size (small , normal , large and xlarge) shall map against each density. Because every size can have different density, right?
If yes, then we can say small screen have all the density i.e ( ldpi , mdpi , hdpi , xhdpi)
same for normal, large and xlarge.
The point is how I'll manage them in my drawable directories.
Will there be four folders for small screen size with different size (drawable-small-ldpi, drawable-small-mdpi, drawable-small-hdpi, drawable-small-xhdpi)?
And same for other screen sizes as well.
If not then how I'll manage all the image in ( drawable-ldpi , drawable-mdpi , drawable-hdpi , drawable-xhdpi) folder because different screen size I'll have different size of images. Then how can a small device with different density and large device with a different size be manageable in same density folder.
Please don't give me reference of any Android document as I read all that stuff.
If any one can't get my point, then please let me know. I'm very confused.
When I have started development in Android, I was confused about same issue.But now I have figured it out and I'm doing pretty well.
Anyways, You are absolutely right.you can provide different images by 4 folders for each.i.e.: drawable-small-ldpi, drawable-small-mdpi, drawable-small-hdpi, drawable-small-xhdpi
But it is just waste of your time.because you don't need to worry this much about it.Android can scale up/scale down according to the device configuration.so just provide extra images for those devices only if you don't get desired outputs for them.
As far as I know, supporting multiple devices, you have to consider few general criteria in your mind.
Density qualifiers: ldpi,mdpi,hdpi,xhdpi,etc are generally used when you want to provide different resolution images.
Size qualifiers + Orientation qualifiers: small,normal,large,xlarge,sw600dp,normal-land,normal-port,etc are generally used when you want to provide different layout designs.
i.e.: single pane layout,multi-pane layout,different elements in layouts according to different screen sizes.
For reference: Download the example app from here and try to understand how it is being supported for multiple screens.
I hope it will be helpful !!
Here are official docs for you to read about the subject: Supporting Multiple Screens then Supporting Different Screen Sizes
Put your all image in all different folder that is drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi and drawable-xxhdpi. android will take care of it.
What I always do is just put all my images in one folder (usually xhdpi). The Android system will scale them for you so you don't have to worry about what to put in what folder.
Heres what Android says about this:
Provide different bitmap drawables for different screen densities
By
default, Android scales your bitmap drawables (.png, .jpg, and .gif
files) and Nine-Patch drawables (.9.png files) so that they render at
the appropriate physical size on each device. For example, if your
application provides bitmap drawables only for the baseline, medium
screen density (mdpi), then the system scales them up when on a
high-density screen, and scales them down when on a low-density
screen. This scaling can cause artifacts in the bitmaps. To ensure
your bitmaps look their best, you should include alternative versions
at different resolutions for different screen densities. The
configuration qualifiers you can use for density-specific resources
are ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high).
For example, bitmaps for high-density screens should go in
drawable-hdpi/.
You can find the documentation here:
https://developer.android.com/guide/practices/screens_support.html
Hope this helps
I want to make my application to multiple screen support. so to achieve this i read the Android developers guildeline https://developer.android.com/guide/practices/screens_support.html and i have created the different drawable and layout folders to put different size of images.
I tested the application in different devices and it looks fine in those devices, while i found that in one of 7" tablet the images are too small. to confirm this i created simple project and put same name of images in different folder and found that this device uses ldpi drawables and in generally the size of ldpi drawable used to be 36x36 and that causes the issue, if i increase this drawable size then it will not compatible with other low-density devices.
Here is the Dispaly Metrics of the device in which i am having a problem.
{density=0.75, width=800, height=444, scaledDensity=0.75, xdpi=160.0, ydpi=160.42105}
How to deal with this problem ? if anyone have this issue before then please give me some advice. any idea and help will be appreciated.
Thanks & Regards
You can get more control over this:
Specify multiple different images for different screen resolutions and densities. To do so read supporting multiple screens. If you need even more precision in image scaling and quality you can use the fundamental size of screen attribute which is sw<N>dp - you can specify the smallest width of the screen where your image should be used. This is a qualifier name for a resource folder.
Some values you might use here for common screen sizes:
320, for devices with screen configurations such as:
240x320 ldpi (QVGA handset)
320x480 mdpi (handset)
480x800 hdpi (high density handset)
480, for screens such as 480x800 mdpi (tablet/handset).
600, for screens such as 600x1024 mdpi (7" tablet).
720, for screens such as 720x1280 mdpi (10" tablet).
Just specify your device width and put your edited image that fits the best in corresponding sw<N>dp folder in your case sw<444>dp.
You should also have a look at other qualifiers that make Android choosing image at runtime (screen density, Available width, Available height, Screen size or Screen aspect). By combining these qualifiers and testing carefully you will be sure that the user has the best experience on each device.
Shortly, put your image under drawable-sw<444>dp folder. (444-smaller screen metric)
In my application I have a background for activity. This is an image, I am going to use fitXY for it. I am ok if it will be resized a little (keeping aspect ration is not very important) but not very much.
I am going to prepare few images with different size and for both Portrait and Landscape orientation. I am going to cover about 90% of devices.
My question is the following:
What images sizes I need for background?
What folders under "res" I should put these images?
I would like to get very specific file sizes and folder name where to put these files.
The solution should work on tablets as well.
I just used two images with maximum sizes (one portrait and one landscape). Then android resized the to smaller and it looks quite good for me.
I have one background with resolution: 800*1200 px in drawable folder
and another with resolution: 1200*800 px in drawable-land folder
This works pretty fine on tablets.
You have to create multiple resources for your app. Android has 4 resolutions (ldpi,mdpi,hdpi and xhdpi) and 4 generalized screen sizes (small, medium, large and extra large). So you have to make 4 layouts (or 3 if you don't plan on supporting tablets, since tablets come under the extra large category) to support the screen sizes.
Here's a general guide:
put layouts for small, medium, large and extra large in your res/ folder as follows:
res/layout/sample_layout.xml // default layout
res/layout-small/sample_layout.xml // layout for small screen size
res/layout-large/sample_layout.xml // layout for large screen size
res/layout-xlarge/sample_layout.xml // layout for extra large screen size
you can also use
res/layout-land/sample_layout.xml for landscape orientation for all screen sizes or you can target landscape layouts for specific screen sizes as res/layout-medium-land/sample_layout.xml
note that all the layouts have the same name.
once you have your layouts ready, you need to take care of image resolutions also
once again in your res/ folder add images like this:
res/drawable-ldpi/sample_image.png // low density
res/drawable-mdpi/sample_image.png // medium density
res/drawable-hdpi/sample_image.png // high density
res/drawable-xhdpi/sample_image.png // extra high density
once again, all the images have the same name.
general guidelines for designing images are:
ldpi is 0.75x dimensions of mdpi
hdpi is 1.5x dimensions of mdpi
xhdpi is 2x dimensinons of mdpi
generally, I design mdpi images for a 320x480 screen and then multiply the dimensions as per the above rules to get images for other resolutions.
Android will automatically select the best combination of layout and image depending on the device. For example, for a high resolution medium size device, layout-medium and high density image will be displayed to the user.
Make sure you create emulators for all these combinations and test your app thoroughly. here's the official docs for more info:
https://developer.android.com/guide/practices/screens_support.html
m/h/xh dpi are the most important. Combine that with the (most common) resolutions and you should be fine for your "90%" target.
I have written an android application, but I find that the graphic of app has different performance in different size of android phones. Some graphics will even become very bad in Tablet. Hence, I would like to know how to adjust the code of program so that the app can adapt difference size of android phone and tablet automatically. Thanks!
There are two important parameters which needs to taken cared when you are designing an app which
should run on multiple devices:
size(physical size of the device)
density of the device
Size: Size of a device in android is not defined as a unique physical value but as a range.
These are: small, normal, large and xlarge.
Density: Density is also defined as a range.
These are: ldpi, mdpi, hdpi and xhdpi.
For handling size you need to use have multiple layouts, one for each category of the size and you need to use different dp value for the height and width of the views for each of the layout as the sizeof a small and a large device will not be same.
For handling density you need to using different drawables for different screen densities i.e you need to place different density drawables in different drawable folders.
Eg:
These are the resolutions for a particular drawable
36x36 for low-density (placed in drawable-ldpi)
48x48 for medium-density (placed in drawable-mdpi)
72x72 for high-density (placed in drawable-hdpi)
96x96 for extra high-density (placed in drawable-xhdpi)
The ratio for this variation of the resolution is 3:4:6:8(ldpi:mdpi:hdpi:xhdpi)
For further reading you can refer to this android developer's link:
http://developer.android.com/guide/practices/screens_support.html
Use Relative Layout
Prepare Graphics for every density (ldpi, mdpi, hdpi, xhdpi)
Nine patch your graphics.
Use WaitSum in xml layout.
Waitsum is automatically set layout and views in different size density.
I have created four versions of my launcher icon for ldpi, mdpi, hdpi and xhdpi devices. They are of dimensions 36x36, 48x48, 72x72 and 96x96.
I'm wondering what will happen when using a large screen. Consdering large screens are rouglhy 7" + in size a ldpi, large screen will surely not want a 32x32 icon image, located in a drawable-ldpi folder.
I cannot find anything on the dev guide that indicates what icon sizes to assign to large and xlarge devices. Presumably I would put a larger copy of the icon in the drawable-large and drawable-xlarge folder. However, I do not know what sizes to use. Does anyone have any recommendations?
Google provide an online tool called Android Assest Studio which creates the launcher icons in the correct size for you. http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-launcher.html
A 7-10" tablet doesn't need anything unusually large. You don't need anything bigger than a 96x96 launcher icon for this use case. There is a table in the Launcher Icons section of the design docs that shows which sizes correspond to which densities.
Have a look at the Declaring Tablet Layouts section of the design docs for more info on how to organize resources for 7-10" screens. (Note that the resource used will depend on the screen density, it is possible that a 7" tablet will have an mdpi screen.)