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.
Related
https://developer.android.com/training/basics/actionbar/adding-buttons.html
The icon attribute requires a resource ID for an image. The name that follows #drawable/ must be the name of a bitmap image you've saved in your project's res/drawable/ directory. For example, "#drawable/ic_action_search" refers to ic_action_search.png.
how to add image to res/drawable/ ?? What size image needed for each type, like xxxdpi,xxdpi
For your First Answer Please Visit Android ImageView example.Copy the image and paste into Eclipse/Android-Studio in the res/drawable directory.
The image name should be in lowercase, otherwise it will end up with
an error.
You should always provide bitmap resources that are properly scaled to each of the generalized density buckets: low, medium, high and extra-high density. This helps you achieve good graphical quality and performance on all screen densities.
To generate these images, you should start with your raw resource in vector format and generate the images for each density using the following size scale:
xhdpi: 2.0
hdpi: 1.5
mdpi: 1.0 (baseline)
ldpi: 0.75
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:
Project/
res/
drawable-xhdpi/
awesomeimage.png
drawable-hdpi/
awesomeimage.png
drawable-mdpi/
awesomeimage.png
drawable-ldpi/
awesomeimage.png
Any time you reference #drawable/awesomeimage, the system selects the appropriate bitmap based on the screen's density.
For more details
http://developer.android.com/guide/practices/screens_support.html
Reference
You should consider mdpi as you base and using that you can create for hdpi, xhdpi and so on
eg. if you mdpi size is 12px X 12px then for hdpi it should be 18px X 18px as hdpi is 1.5 times mdpi
use this link
About Android image and asset sizes
Drag drop image using finder/explorer
Use android design guidlines for icon size ratios
Just copy your images from your syaytem to drawable directory of your project
And for icon sizes you can refer to this answer
https://stackoverflow.com/a/12768159/4211264
What size image needed for each type, like xxxdpi,xxdpi
for icon size.. please refer this site
http://iconhandbook.co.uk/reference/chart/android/
Go to YourProjectName/res/drawable and save your image in this folder.
If u have different sizes you can also use the different drawable folders.
If it is one image for every size just create the new folder "drawable" and save your image there.
If I define drawables for a density qualified folder (eg drawable-hdpi), and also drawables to fall back on in drawable-nodpi, will a high density device use the -hdpi over the -nodpi?
What about if I take it a step further and also have the same setup for -land folders.
I'm not sure what the precedence is for nodpi, but that should never be a problem. It sounds like you are misunderstanding the nodpi qualifier. You should not use nodpi as a fallback for assets that you don't provide at the device's density bucket. The correct fallback is a folder with no density qualifier (e.g. drawable/).
If the system cannot find an asset at the device's density (e.g. it is an ldpi device and you don't have a drawable-ldpi folder), it will fall back to a folder without a density qualifier, *not the nodpi qualifier`.
The nodpi qualifier is used when you want to specify a resource that will be used for all densities and that you do not want Android to scale. Assets in the other density folders (e.g. drawable-xhdpi) will be scaled to the actual screen size. If you use the nodpi qualifier, you should not provide that asset in any other resource folders.
It is also important to note that with screen density qualifiers, Android will also prefer to use a lower density asset over an unqualified resource. If you have an xhdpi device, but you only have a drawable and a drawable-mdpi folder, Android will check for the asset in the mdpi folder before the unqualified folder.
drawable-nodpi will bypass scaling and drawable will use the default scaling:
mdpi = 1x
hdpi = 1.5x
xhdpi = 2x
xxhdpi = 3x
xxxhdpi = 4x
drawable-nodpi is efficient if your code will be doing its own scaling
(or no scaling) and you don't want the image pre-scaled by Android.
There is also drawable-anydpi, just to make things more confusing.
drawable with no specifications will be used if an exact match on density and screen specifications does not exist. drawable-nodpi will be used after drawable.
UPDATE If you have both drawable and drawble-nodpi, the select order is either a more complex rule not documented or Android is broken. Through experimentation I confirmed that devices with screen density < xhdpi will correctly select the drawable image. Devices with screen density >= xhdpi will select the drawable-nodpi.
Selection rule:
1. Pick match to screen density, one of these:
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
If no match on density, then select one of these
drawable (automatic scaling mdpi=none... xxxhdpi=4x)
drawable-nodpi (no scaling)
drawable-tvdpi
drawable-anydpi (no scaling)
It depends.
First of all nodpi is not a fallback folder. If you have a hdpi device, the system will look for hdpi folder first. nodpi folder contains resources that are not meant to be scaled.
drawable/ can be used as a fallback folder in case device density specific resources are not present.
Then, if we look at the possible Qualifier Values for the Screen Pixel Density(dpi), these are listed as:
ldpi
mdpi
hdpi
xhdpi
xxhdpi
xxxhdpi
nodpi (Non-scaling resources go here)
tvdpi
anydpi (Resources in this folder take highest precedence)
nnndpi
Note: You should put all those resources in the drawable-nodpi folder that you do not wish to be scaled. To support multiple screens, Android prefers to scale down a larger original image instead of scaling up a smaller original image. These resources should not be present in any other drawable-qualifier folder else these might be scaled which kind of defeats the whole purpose.
It must also be noted that:
Using a density qualifier does not imply that the resources are only for screens of that density. If you do not provide alternative resources with qualifiers that better match the current device configuration, the system may use whichever resources are the best match.
Here is the Resource Selection Flowchart that the system uses to find the best match:
The drawable-nodpi qualifier is used when image/asset is not need to be scaled.
Drawable in the other density folders (e.g. drawable-xhdpi) will be scaled to the actual screen size.
drawable-nodpi for constant size in all density devices.
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
Perhaps we use one image for all ldpi, hdpi, mdpi and xdpi where we need to keep the image(in which folder). This is a bit confusion to me. Can anybody clarify my confusion?
Just keep it in res/drawable.
This is not recommended as the images you use will then not scale well for different device screen sizes. But if you place an image in res/drawable this will work.
Instead of creating all of the different folder buckets, drawable-ldpi, drawable-hdpi, etc. Just create one folder, drawable, and then put your images in there and when Android searchs for the image and doesn't find the other folders it will default to the drawable folder as the only resource. This folder is understood by Android to be equal to the drawable-mdpi and will scale the images accordingly.
EDIT: Also available is the res/drawable-nodpi, This will not scale your image at all and it will retain the same size on all screens.
Take a look at How to Support Multiple Screens
The "default" resources are those that are not tagged with a configuration qualifier. For example, the resources in drawable/ are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate.
So yes, drawable folder is what you are looking for.
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.