I have a .xml file representing a shape and 5 drawable-*** folders (for hdpi, ldp, mdpi, xhdpi, xxhdpi).
Since this is a shape, I assume I only need one copy? Should I create a folder called drawable and place it in there? Or do I need one copy of the shape in each of the resolution specific folders?
Yes, you can have a res/drawable folder, i.e. no suffix. It will be used for all resolutions. You can also use the -nodpi suffix, see Supporting Multiple Screens for details.
Related
I am very curious what kind of size of images I have to hold in Resources -> drawable folder.
Because in other drawable folders like mdpi, hdpi and etc I am holding size of images regarding documentation. As I know in drawable folder there should be default images if device do not recognize what kind of type of drawable folder is required, then application loads from default folder - drawable. So what kind of size images, you would suggest to put? Thank you for all answers and suggestions.
Well, I find out that is mostly recommended to have images in drawable folder(default) from drawable-hdpi folder.
And here is recommended sizes for each folder: http://iconhandbook.co.uk/reference/chart/android/
My problem is that I have to put identical copy of drawables for both drawable-mdpi and drawable-tvdpi.
Target devices density are tvdpi and xhdpi.
I want that device(xhdpi) fatch drawable resources from drawable-mdpi rather then drawable-tvdpi. For this what I need to do? And how? May be by custom build file it can be solved, but don't know how to do that?
Any time you reference #drawable/image, the system selects the appropriate bitmap based on the screen's density.
res/
drawable-xhdpi/
image.png
drawable-tvdpi/
image.png
So you need not do anything for the device to fetch the appropriate drawable resources .
Only thing is to add the image properly in the folder with standard pixel size .
Ok so I have 4 folders in my res directory: drawable-mdpi,drawable-hdpi,drawable-xhdpi,drawable-xxhdpi. I wanted to know how to make a DEFAULT drawable folder where I could place images and if there was no image found in the specific density folders, the android device would look in the defualt one. So I created one with no qualifiers named drawable. The problem is when I put an image in my new created folder, it appeared differently than when I placed it in a specific density drawable folder.. Even though I was using the exact same image. How did changing folders affect my image..?
The default drawable folder will be interpreted as mdpi, essentially. So any image you put in there will be rendered 1:1 on an mdpi device, scaled to 1.5x on hdpi, and scaled to 2x on xhdpi, etc.
All those folders are related to the phone you are using, you can open a default drawable folder named "drawable" but if you want to know, the drawable-mdpi for example is for samsung galaxy tab 10" (and more), you can read more here: http://developer.android.com/guide/practices/screens_support.html
I have 2 doubts regarding storing the drawables in respective folders ie.. ldpi, mdpi..Which I couldn't find an answer anywhere.
I have folders like this:
Since I have all the possible folder names ie.., ldpi, mdpi, hdpi, xhdpi, xxhdpi should I delete the default drawable folder?
Or Should I move all the files from drawable-mdpi to the default drawable folder and delete the drawable-mdpi folder?
I am using few xml files as drawables, which are selectors, custom backgrounds etc.. Which contain the image references like
<item android:drawable="#drawable/ic_vote_clicked" android:state_pressed="true"/>
<item android:drawable="#drawable/ic_vote_clicked" android:state_focused="true"/>
<item android:drawable="#drawable/ic_vote"/>
Where should I place these xml files? In every folder? Or the default drawable folder?
Anyways the pngs like #drawable/ic_vote are in every folder.
Anything that is not DPI related should go in the drawables folder.
Anything else that is dpi related, should be in the relevant DPI folder.
There is no reason to delete any of the folders.
So your xml files should be in the drawable folder.
Also, it doesnt matter what folder they are in, you still reference them with #drawable/ and it finds the right one.
Android first checks for the resource in the corresponding density specific folder, example: ic_launcher.png for a medium density screen will first be searched in the drawable-mdpi folder. If found, well and good. In case, the image doesn't exist there, android picks from the drawable folder, the default.
hence, to have image resources specific to density, keep them in respective folders and a copy in the drawable folder as well [only for the safe side].
For the xml resources, keep them in the drawable folder only.
Hope that helps.
I created five folders for drawable i.e. ldpi, mdpi, hdpi, xhdpi and xxhdpi. Also for layout i created three folder i.e layout, layout-large and layout-xlarge.
My project requirement was Multiple Device Support. It worked well on all the devices.
Issue was with 10 inch and 7 inch tab. To solve this issue i created layout-large and layout-xlarge folders and place the respective files in respective folders. And now everything is working fine.
So its highly recommended that you create respective folder. Don't move everything to drawable or layout folder.
Put the xml files in default drawable folder. Don't change others.
You shound't delete any of this folders.
Drawable-density folders are using in all element which you want to add i.e. png files. In drawable folder you can add universal graphics, specified i.e. using XML structure (selectors etc.)
How can I make 2 separate layout folder for
screens that are xxhdpi, and screens that are everything else?
Thanks!
I have right now just a layout folder for all my layouts
You can have folders under /res that are named as follows (where "xxhdpi" refers to the Density):
layout
layout-xxhdpi
However, you may actually be referring to the Size of the screen itself, which can be:
layout
layout-xlarge
as an example...
Please refer to the Android Providing Resources docs for more information on the flavors of folder names for resources.