Android drawable mdpi - android

I am working on a Android Project.
I put the images (320*480) into the mdpi -folder. There are some information in Android developer site that 480*800 tablets(7") also takes images from the mdpi- folder. When the 7" tablet takes images form that mdpi- folder it become smaller. There is only one mdpi- folder so how do i exactly manage it .

You should read the Android developer documentation on Providing Alternative Resources.
From my answer to this similar question:
The ImageView will render the image inside of it at the correct resolution for the device. As per the documentation on providing resources, you must make sure that you provide resources at the correct DPI for each of the resolution types. Android will pick the best resource resolution for you, but if only one resource exists then it will pick that one and try to render at the device resolution.
So, find out the correct DPI for your device, and add the image (at the correct DPI) into that folder and it should appear at the correct size. If the image is placed in the wrong folder then it will appear a different size. Another useful link is the Density Independence documentation.
Note: let's assume your device is an HDPI device. The res/drawables/drawable-hdpi folder might not exit in your project but you can just add it in manually.

Don't mix up screen size with screen density. There are qualifiers related to screen size (e.g. small, normal, large, ...) and qualifiers related to density (e.g. ldpi, mdpi, ...).
You can even combine these qualifiers, for example in drawable-normal-mdpi you can put resources that will be used on devices with normal screen (phones) with a mdpi density.

you should create ldpi, hdpi, xhpi folder too. And you need to copy your image with same name by calculating its ratio.
ldpi - mdpi - hdpi - xhdpi
3 4 6 8
There is a 3:4:6:8 scaling ratio between the four primary densities
(ignoring the tvdpi density). So, a 9x9 bitmap in ldpi is 12x12 in
mdpi, 18x18 in hdpi and 24x24 in xhdpi.
If you decide that your image resources don't look good enough on a
television or other certain devices and want to try tvdpi resources,
the scaling factor is 1.33*mdpi. For example, a 100px x 100px image
for mdpi screens should be 133px x 133px for tvdpi.

Related

Android Application Background Resolution

I want to design a background for android application using Photoshop , let's say I have Samsung S4,So I set the resolution to the maximum of that device which is 1080x1920 and 441dpi
Now,my question is where should i insert it in what subfolder of Resources and depending on what we choose that folder
-drawable-hdpi
-drawable-ldpi
-drawable-mdpi
-drawable-xhdpi
-drawable-xxhdpi
What image feature decides on which folder image should be in?
Hopefully, this image will show you which category it falls into:
As you can see everything larger than 400dpi is xxhdpi, so you should place it there.
Also check out the DisplayMetrics page.
EDIT: To answer your last question. There isn't any image feature that determines where it belongs, the folders are simply used to load images with different resolutions onto different screens. For example if the picture containing text has high resolution and you place it on a low density screen, the text would be (physically) too small to read. So you place a higher resolution image in hdpi or xhdpi folder and resize it so it has smaller resolution and place it in ldpi and mdpi folders.
Please refer to this, it is from google!
http://developer.android.com/training/multiscreen/screendensities.html
You should put on drawable-xxhdpi folder.
A brief explanation about the drawable resources:
The drawable resources are, by default, divided in 6 generalized groups based on its pixel density:
ldpi: Low density drawables (~120 dpi)
mdpi: Medium density drawables (~160 dpi)
hdpi: High density drawables (~240 dpi)
xhdpi: XHigh density drawables (~320 dpi)
xxhdpi: XXHigh density drawables (~480 dpi)
xxxhdpi: XXXHigh density drawables (~640 dpi)
The scaling ration between these drawables should be 3:4:6:8:12:16
You only need to provide density-specific drawables for bitmap files (.png, .jpg, or .gif) and Nine-Path files (.9.png). If you use XML files to define shapes, colors, or other drawable resources, you should put one copy in the default drawable directory (drawable/).
Even if you don't provide alternative drawable resources for the different groups of density, the Android system will find the best matching drawable and scale it for you. But is recommended to provide alternative drawable resources in order to ensure to always have smooth drawables in all devices.
You might want to take a look here.

Android different screen size and different densities [duplicate]

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

Working with different screen sizes and different densities for resource drawables

I'm preparing drawables for my app. After some research, I came to know that 3 parameters that needs to be considered are Screen-size, Density and Resolution.
1.) Since for a particular screen-size, if density varies then corresponding resolution will automatically vary. Also, for a particular density, if screen-size varies then corresponding resolution will automatically vary.
Going by this logic, I removed resolution from consideration and planned to concentrate only on screen-size and density. Am I correct in this approach?
2.) Now as per documentation, if you are preparing 100x100 image for mdpi, then you should have 75x75 and 150x150 image for ldpi and hdpi respectively.
So I created an image resource drawable (.png) of size 100x100 with density 160 (mdpi). Then I created the same image with size 75x75 with density 120 (ldpi) and 150x150 with density 240 (hdpi) and placed them in respective drawables folders.
But after doing this, when I run the app on emulators having combination of different screen-size and different densities, the drawables just doesn't fit-in properly in the given space.
In some smaller screen-sizes, 3rd icon is getting cut halfway through.
Am I doing something wrong?
Any help appreciated.
Refer this:
You have to put your images in res/drawable folder by convention.
In res folder there could be more than one drawable folder like res/drawable-ldpi, res/drawable-mdpi, res/drawable-hdpi, res/drawable-xhdpi, and res/drawable-tvdpi.
You might be creating an app for different phones with different screen resolutions and screen sizes.
Android have a categorization of phone screens according to the dpi of the screen, namely ldpi, mdpi, hdpi, xhdpi, tvdpi (low, med, high, xtra high, tv respectively).
Your goal is to add each copy of images to these folders for each type of your target devices. For that you have to resize your images in the dpi ratio.
3:4:6:8 is the default dpi scaling ratio
More

What resolution of Drawables i should use for this display metrics?

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)

How to make the graphic automatically adapt difference size of android phone and tablet?

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.

Categories

Resources