Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Hi as per android documentation the drawable folder needs to have multiple sub-directories for images of different dpis. However in Android Studio creating any sub directory in the drawable folder causes it to fail to detect any images at all. On the other hand if an image is placed directly in the drawable folder it gets detected and becomes available for use view R.drawable.ImageName. In this case how do we use different dpi images for the same ImageName?

like image 937
praveen Avatar asked Mar 27 '15 06:03

praveen


People also ask

How do I add an image to a drawable XML file?

Step 1: In this method first of all in your system find your required images and copy the image as we do normally. Step 2: Then open the Android Studio go to the app > res > drawable > right-click > Paste as shown in the below figure. Step 3: Then a pop-up screen will arise like below.

How do I add an image to a Visual Studio drawable folder?

Go to the solution explorer, select Resource--> drawable. Right click --> add--> Existing Item. or (Shift + Alt + A).


2 Answers

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
like image 198
KimNguyen Avatar answered Sep 28 '22 02:09

KimNguyen


There are two ways of doing it.

1.Right click on drawable New->Image Asset-> select your highest resolution image rest will be created automatically. once you finish you can see different resolution inside drawable folder

  1. The way you want. on the project Explorer window you see a dropdown as Android. Click it change to project.

Now yourprojectname->app->src->main->res->

Aila You can see your drawable folders with hdpi mdpi etc.

like image 38
Dhinakaran Thennarasu Avatar answered Sep 28 '22 01:09

Dhinakaran Thennarasu