Reputation: 1061
I am using Android Studios 1.5
I am attempting to do something very simple: Add a large image to my project that I will be using as the background for my MainActivity. When I right click res->Add->Image Asset and choose "Action Bar and Tab Icons" and point it to my image, it renders completely blank rectangles as seen below:
What am I doing wrong? I've read several different pages and no one else has had this problem.
Upvotes: 10
Views: 8019
Reputation: 241
Please know I am using Android Studio Bumblebee | 2021.1.1 Patch 3.
The Android's Docs recommends : "512 x 512 pixel image [is] appropriate for the Google Play store" https://developer.android.com/studio/write/image-asset-studio
However, the Android's Docs seems silent on the recommended size for "Action Bar and Tab Icons". https://developer.android.com/studio/write/image-asset-studio
If you want to add a large image:
Go to Andorid Studio File -> New -> Image Asset
Open the “Icon Type” drop-down and select “Action Bar and Tab icons.”
Enter your icon name.If your project already contains an icon with the same name, then Image Asset Studio will warn you before replacing the original resource.
Choose the asset type you want to use.In our case it is an Image. To use an image that’s stored locally, select “Image,” then click to choose an image from your hard drive.
Choose trim to adjust the margin between the icon graphic and border in the source asset. Removes any transparent space between the icon graphic and the icon border, while preserving the aspect ratio.
There will be a slider to adjust the padding of the icons. You can use it to adjust the amount of space around your icon.If you also select Trim, the trimming happens first.
Theme. Choose between “HOLO_LIGHT” or “HOLO_DARK,” or create your own theme by selecting “CUSTOM.”
Now click the "Next" button. it will take you to a confirmation page. The following screen displays the directories where the different density-specific icons will be stored.
Click the "Finish" button. Image Asset Studio will generate your icons, and place them in the appropriate directories.
Upvotes: 0
Reputation: 1
I had the same problem. So I added once by importing the image. But I wanted a different icon, so I tried to add second time but I was getting that black icon instead. So the solution is whenever you try to add second time just clear the old path first the import the new path. The reason is whenever you try to add any image asset more than once instead of clearing the old path and adding the new path in the path textfield, the path of your new image asset gets appended to the old one which is why it creates a blank image.
Upvotes: 0
Reputation: 1061
Alright I figured out the answer.
You can't add it through the Android Studios interface (why is beyond my comprehension..). You need to go to the root folder of your project to ...\app\src\main\res\drawables and copy the image into all of the respective hdpi, mdpi, xhdpi, etc folders. Then clean your project and they will appear.
Upvotes: 10