How to Add Image to Drawable Folder in Android Studio?
The resource folder is the most important folder because it contains all the non-code sources like images, XML layouts, UI strings for the android application. In Android Studio inside the res folder, one can find the drawable folder, layout folder, mipmap folder, values folder, etc. Among them, the drawable folder contains the different types of images used for the development of the application. We need to add all the images to the drawable folder for the application development. Images are used in android applications to provide more user-friendly behavior & functionality. So in this article, we are going to discuss how to add an image to the drawable folder with multiple methods being explained step by step.
In method 1 we will do it through the way Android Studio provided to you.
Step 1: Open Android Studio and go to the app > res > right-click > New > Image Asset as shown in the below figure.
Step 2: A pop-up screen will arise like below. Here choose Action Bar and Tab Icons in Icon Type.
Step 3: Then choose Asset Type as Image and enter the Path of your image. Enter the name of your image and click on Next.
Step 4: Now you can see the android studio automatically created the different-sized images. You can directly create the folder and drag image inside but you won’t have the different-sized icons if you do that and this the main advantage of following this method. And finally, click on the Finish button.
Now go to the app > res > drawable and you can find a folder named as image and the different sized images inside this folder as shown in the below image.
- drawable-ldpi (low-density): Lower images quality supported by the earlier sets of the android – 240×320 pixels
- drawable-mdpi (medium-density): For medium images support – 320×480 pixels
- drawable-hdpi (high-density): Images for the Android Broad Screen set or Android Phones with the Higher resolution – 480×800 pixels
- drawable-xhdpi (extra high-density): Devices with maximum resolution – 720×1280 pixels
Method 2 is very easy but as we discussed above we can directly create the folder and drag image inside but you won’t have the different-sized icons if you do that and this the main advantage of method 1. So the developer must follow method 1. Below is the step by step implementation of method 2:
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. Here choose your directory where you want to store your image file. And click on OK.
Step 4: In this screen, you can rename your image file name and also choose your directory. And click on the Refactor button. And you are done.
Now go to the app > res > drawable and you can find a file named as method_2.jpg as shown in the below image.