73

In Android Studio, I can't figure out where to put images to be used inside the app. The drawable folder isn't broken down into drawable-hdpi, drawable-ldpi, etc. I saw another question asking this and the answer was to switch to Project view instead of Android view but drawable is only one folder there too. There is mipmap-hdpi, mipmap-ldpi, etc, but people are saying that's only for app icons. I'm confused.

user3397545
  • 787
  • 1
  • 5
  • 8

9 Answers9

96

Actually you have selected Android from the tab change it to project.

Steps

enter image description here

Then you will found all folders.

enter image description here

IshRoid
  • 3,408
  • 2
  • 22
  • 36
  • 9
    I'm new to Android as well and experiencing the same issue. It's really not a bit deal to create the subfolders but I found it a little disorienting while trying to follow a tutorial to have the default folders missing. Moreover, the tutorial instructions were to drag and drop images into the drawable folder in Android Studio and that didn't work either. Just so you know in the latest version of Android Studio the subfolders do not exist in Project mode either. – mba12 May 21 '15 at 21:14
  • Just Write click on res folder after expanding folders, Then create new Directory, named it your desire DPI folder – IshRoid May 25 '15 at 06:26
  • 2
    would have been nice that what difference does it makes in Project vs Android selection. To me Android defines everything that means to apk. where as project is just an explorer. Overall I m happy I found the magic through you :) – codebased Jun 07 '15 at 07:33
  • 4
    i'm using Android Studio 1.2.1.1 i don't find the default folders even in project selection but have some folders like mipmap-hdpi,mipmap-ldpi etc – NaveenThally Jun 13 '15 at 07:24
  • for mipmap folders this link will explain http://stackoverflow.com/questions/28065267/mipmap-vs-drawable-folders – IshRoid Jun 17 '15 at 11:40
  • I have a question. I have put all the appropriate images in all the appropriate folders, but when I try to make an `ImageView` with the `android:src = "@drawable/myimg"/>, I get cannot resolve. Do I need the image to also be in the drawable folder as well as the sub folders? I have been stuck on this for the last 4 and a half hours, thanks for your help! –  Jan 23 '16 at 06:20
47

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.

yole
  • 80,603
  • 15
  • 224
  • 177
  • 3
    I suppose I'll do this. I'm curious why the folders aren't there though when they should be there. – user3397545 Feb 28 '15 at 17:38
  • 1
    Why exactly do you think they should be there? – yole Feb 28 '15 at 17:43
  • 1
    But hey what was the need to remove default folders? and changes like showing bar left side of braces are also have been changed. You guys are degrading the UI of Android Studio in each update. – Krupal Shah Apr 30 '15 at 14:44
  • In ["Supporting Multiple Screens"](http://developer.android.com/guide/practices/screens_support.html), under "Using Configuration Qualifiers", Google explains you have to have to do it yourself, just as @yole explained. It's in the documentation. – Timothy Steele Dec 28 '15 at 17:48
  • 3
    @yole Because they were there in Eclipse. Also, whilst it is understandable that separate folders exist for mipmap (as they are usually pre-populated with the launcher icons), not having separate folders when Android Studio creates the project does introduce an inconsistency - which many wouldn't expect or immediately understand. – ban-geoengineering Jan 04 '16 at 12:00
  • I have a question. I have put all the appropriate images in all the appropriate folders, but when I try to make an `ImageView` with the `android:src = "@drawable/myimg"/>, I get cannot resolve. Do I need the image to also be in the drawable folder as well as the sub folders? I have been stuck on this for the last 4 and a half hours, thanks for your help! –  Jan 23 '16 at 06:20
  • @user5562706 No, everything should work just fine. Try to clean your project. Cleaning works wonders. I hope it works for you. –  Jun 07 '17 at 03:36
  • Simply go to project Explorer and change your View from Android to project from drop Down and you are good to go.There you can simply create folder like we do in Eclipse. And in android project view it is hidden but when you switch to project. You can create folder like drawable-hdpi,drawable-xhdpi. – Mohit Raval Sep 05 '17 at 14:09
15

In order to create the drawable directory structure for different image densities, You need to:

  1. Right-click on the \res folder
  2. Select new > android resource directory
  3. In the New Resource Directory window, under Available qualifiers resource type section, select drawable.

  4. Add density and choose the appropriate size.

jungledev
  • 3,679
  • 1
  • 32
  • 47
KBJ
  • 165
  • 1
  • 7
6

In Android Studio 1.2.1.1

Just copy the image and paste the image into the app > res > drawable folder and it will shows you "Choose Destination Directory" popup screen as shown below screen

enter image description here

Now you can select option whatever resolution you want to place and if you want to view the those image into the folders then simply right click on the drawable folder > select copy paths option and open it. It will help you.

Amandeep Rohila
  • 3,302
  • 2
  • 24
  • 32
5

Its little tricky in android studio there is no default folder for all screen size you need to create but with little trick.

  • when you paste your image into drawable folder a popup will appear to ask about directory
  • Add subfolder name after drawable like drawable-xxhdpi
  • I will suggest you to paste image with highest resolution it will auto detect for other size.. thats it next time when you will paste it will ask to you about directory

i cant post image here so if still having any problem. here is tutorial..

Drawable folder in android studio

kundan roy
  • 1,896
  • 1
  • 16
  • 20
2

There are two cases:

  1. If you are having a single image, irrespective of device version, then you should put your images in drawable folder.

  2. But for the images that you created separately for hdpi, ldpi, mdpi, xhdpi, xxhdpi and xxxhdpi, depending on screen resolution of the mobile that will be using the app, you have to puy them in drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi and drawable-xxxhdpi folders respectively.

For the first case, if there is a single image, you can pretty much place it in any drawable folder, but its standard convention to put them in drawable folder.

rohanpro
  • 157
  • 7
0

This tool creates the folders with the images in them automatically for you. All you have to do is supply your image then drag the generated folders to your res folder. http://romannurik.github.io/AndroidAssetStudio/

All the best.

Ronny Kibet
  • 3,025
  • 4
  • 27
  • 42
0

Just to make complete all answers, 'drawable' is, literally, a drawable image, not a complete and ready set of pixels, as .png

In other word words, drawable is only for vectorial images, just try right-click on 'drawable' and go New > Vector Asset, it will accept it, while Image Asset won't be added.

The data for 'drawing', generating the image is recorded on a XML file like this:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
<path
    android:fillColor="#FF000000"
    android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,
    -0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,
    19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,
    1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,
    1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,
    2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,
    1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,
    0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,
    5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
  </vector>

That's the code for ic_android_black_24dp

0

In order to create drawable-hdpi ,drawable-xhdpi.....and other directories to store different density images we have to::

step1:Right click on res folder

step2:Then: >>new >>Android Resource Directory

step3:From Resource type select "drawable"

step4:From Available quantifiers option select density.

step5:select the ">>" option to see different type of density options.

step6:select the density and click ok.

Then you can see the directory got created.You can follow similar procedure to create other density directories. thankyou.