Drawable Folders in Res Folder

How to create drawable folder in res?

Yes it already exist.

you have to change the project structure

Click on top left dropdown where Android Appears.

Select project from this dropdown and you will be able to see all drawbale folders.

Screenshot

Drawable folders in res folder?

I am going to take a guess that "the three drawable folders" are drawable-ldpi, drawable-mdpi, and drawable-hdpi. In that case, if you stick with all of those folders, you need to put one image in each, sized to match the indicated screen density. This is discussed in the online documentation as well as this blog post. You can find a set of sample projects showing use of different drawable resources based on screen density here.

If you are just starting out in Android development, you can get rid of all three of those directories and create a single drawable directory, putting your image in there. Eventually, though, for a quality application, you will want to test your images on different devices/emulators with different screen densities, and possibly have different images for each density to improve the look of your app.

Is it possible to create multiple directories for drawable in res?

You can't create subfolders for drawables in the res/drawable folder.
See this question here in SO.

Can the Android drawable directory contain subdirectories?

Android Studio: Drawable Folder: How to put Images for Multiple dpi?

The standard procedures are:

  1. Choose Project > app > scr > main
  2. Right click "res", choose "New" and choose "Android resource directory"
    Step 2
  3. In the opened dialog, at Resource Type choose "drawable"
    Step 3
  4. In the list Available qualifier choose Density, then click the right arrow at the middle.
    Step 4
  5. Choose the Density that you like then press OK
    Step 5

Can the Android drawable directory contain subdirectories?

No, the resources mechanism doesn't support subfolders in the drawable directory, so yes - you need to keep that hierarchy flat.

The directory layout you showed would result in none of the images being available.

From my own experiments it seems that having a subfolder with any items in it, within the res/drawable folder, will cause the resource compiler to fail -- preventing the R.java file from being generated correctly.

Android Studio drawable folders

If you don't see a drawable folder for the DPI that you need, you can create it yourself. There's nothing magical about it; it's just a folder which needs to have the correct name.

How to add images to corresponding folders in res/drawable/

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:

  1. xhdpi: 2.0
  2. hdpi: 1.5
  3. mdpi: 1.0 (baseline)
  4. 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

Sample Image
Reference



Related Topics



Leave a reply



Submit