Reputation: 3149
I want to add a bitmap image file (.PNG) to my Android Studio (3.1.4) project. It is not intended to be the small logo that appears as an application icon. On the contrary, it is the application logo that is displayed in large size when the user has just launched the application. This logo will therefore be displayed in the main activity UI which will disappear after 2 seconds, at the end of which the next activity UI will be displayed, which will offer the user all the functionalities of the application. The logo is therefore part of a launcher UI if I can summarize it in this way.
Problem: I'm a little confused because the following documentation says to use Image Asset Studio to add a bitmap image to the project: https://developer.android.com/studio/write/add-resources but the documentation provided there (https://developer.android.com/studio/write/image-asset-studio) seems to only talk about application icons.
cd
Unix command and copy/paste my image in res/drawable
I found a temporary solution: go to the directory of my Android Studio project, go to the src
subdirectory and then place my image in the res/drawable
subdirectory. Except that by doing this: 1) I don't benefit from the program that tries to reduce the weight of the image (read in the documentation, I don't know where) and 2) I might have to put the image in /res/drawable v24
to manage other screen sizes. Thus it's not so clean.
I also found another solution. According to the documentation, I can right-click on drawable
in the Project tab of Android Studio. Then, choose : "new > Drawable resource file". Then I type the name of my image, I select "main" as "Source set", and I let "Directory name" to "drawable". I don't choose any "Available qualifiers". It creates my logo.XML
file. But here, I don't know how to add my image file "logo.PNG".
How could I add this "logo.PNG" to my res/drawable
resource file cleanly? For recall: it's actually the logo of my application, which is displayed in large size in the "launcher" (the main activity's UI) BUT it's NOT the application's icon.
Version of Android Studio : 3.1.4.
Upvotes: 1
Views: 3297
Reputation: 93561
You just drop the image in the drawable directory. If you need multiple versions for different densities, you drop it in all of the appropriate directories. You don't need some weird program.
A drawable xml file is generally used to make either simple shapes without needing to create an image file, or to combine multiple drawables into a state changing or layered drawable. You wouldn't use this for a simple image.
Upvotes: 5
Reputation: 17834
drawable-v24
isn't for different screen sizes, it's for devices running API 24 (Nougat) or later.
If you right click on any file or folder in the project (left) pane of Android Studio, you can then select "Add Image" and add your own image, specifying where it should go.
Upvotes: 2