Importing image into Android Studio, appears as da

2020-07-22 19:49发布

问题:

I am attempting to import an image into Android Studio and then use it as a background for my app. I right click on the res folder and import asset, next I choose action bar and tab icons, here I find the image file on my pc and then import it in my project.

When It imports all the previews are dark grey and then when I place it in my layout I get this:

I am using a PNG which is around 700kb if that makes any difference.

回答1:

I did a variety of things and not sure which one fixed the issue.

First I realised my project wasn't using the gradle wrapper which was causing issues, to fix this I went to file->settings and told Intellij to use the default gradle wrapper.

I then installed the Android Drawable Importer plugin and imported my images with this, works fine now.



回答2:

Right Click on drawable-> navigate to -> New -> Batch Drawable Import-> fClick on the + sign. Choose your image and click OK. It will create the images with different density.

For enabling the Android Drawable Importer plugin you can refer this link http://www.javahelps.com/2015/02/android-drawable-importer.html



回答3:

Try this > In android studio go to the file menu and click, Invalidate Caches / Restart