Saving various density patterns in a folder

I have 2 doubts regarding the storage of drawings in the appropriate folders, that is .. ldpi, mdpi .. What I could not find anywhere.

  • I have folders like this:

enter image description here

Since I have all possible folder names, that is .., ldpi, mdpi, hdpi, xhdpi, xxhdpi , should I delete the selected default folder ?

Or do I need to move all the files from drawable-mdpi to the selected default folder and delete the drawable-mdpi folder ?

  1. I use several xml files like drawables, which are selectors, custom backgrounds, etc. that contain links to images, such as

    <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 to place these xml files? In each folder? Or is the default folder selected ?

In any case, png, such as @drawable/ic_vote , are in every folder.

+4
source share
5 answers

Everything that is not related to DPI should be in the drawables folder.

Everything related to dpi resolution should be in the corresponding DPI folder.

There is no reason to delete any of the folders.

So, your xml files should be in a folder with the ability to transfer.

Also, it doesn’t matter what folder they are located in, you still reference them using @drawable/ and find the correct one.

+7
source

Android first checks the resource in the corresponding density folder, for example: ic_launcher.png for a medium-density screen will first search in the drawable-mdpi folder. If found, good and good. In case the image does not exist there, the android selects from the drop-down folder by default.

therefore, in order to have image-specific density resources, keep them in appropriate folders and a copy in a drawable folder also [only for the safe side].

For xml resources, save them only in a dedicated folder.

Hope this helps.

+2
source

I created five folders for drawing, i.e. ldpi, mdpi, hdpi, xhdpi and xxhdpi. In addition, for the layout, I created three folders: ie layout, layout-large and layout-xlarge. My project requirement is support for multiple devices. It worked well on all devices. The problem was with 10-inch and 7-inch tabs. To solve this problem, I created large and mock-xlarge layouts and placed the corresponding files in the appropriate folders. And now everything is working fine. Therefore, it is highly recommended that you create an appropriate folder. Do not move everything to a drawable or layout folder.

+2
source

Put the xml files in the default folder. Do not change others.

0
source

You do not delete any of these folders.

Dense folders are used in all elements that you want to add ie png files. In the drop-down folder, you can add universal graphics specified, for example, using the XML structure (selectors, etc.).

0
source

All Articles