Are all images in Android apps considered Icons?

守給你的承諾、 提交于 2019-12-10 19:05:25

问题


This has bothered me for a little while now. I may be over reacting, let me know if I am. But, I feel like adding image assets to your Android Studio project is harder than it should be. Not necessarily saying it's difficult to do, but I feel like it should be one of the easiest things to do.

I am a bit new to AS, so I could be way out of line here.

I'm working on a project, and I want to add a test image real quick to put in an image view. Not having done this yet I just assume I can click an image file I have on my desktop and drag into my res/drawable folder in the AS window. I quickly realized I can't. I then realize I can drag the image into the view port in AS and it opens there. I assume I can quickly save it into my drawable assets, but again, no luck.

So the next thing I try is to right click on the drawable folder knowing there will be an add option. I see add a new file. Try that, and it has me tell it what kind of file it is, assuming I'll then be asked to tell it my image's file path and then have it added to the project. Nope! It creates an empty image file with no way (I can tell) of telling it what image I want in my project.

I keep poking around and realize that there's also a New>Asset Image option when I right click the drawable directory. I finally feel relieved. I click on it and it opens up the Launcher Icon settings. I can change the type of image from Launcher Icon, Action Bar and Tab Icons, and Notification Icons. There's actually a file path option, so yeah it worked. I was able to add my image.

But my question is, why are those my only options for images I want in my project. Aren't almost all apps primarily made of images? Why is this process necessary to add every single image? And again, why would an image need to be classified as one of those three option. What about games? I haven't made a game yet, but almost everything in a game is an image asset and NOT an icon.

Is there another completely obvious way to add non icon image assets to your project? Am I completely over reacting, just because I need to label all images as some kind of icon, even though it doesn't really matter? Let me know how ridiculous or right minded I'm being below.

Thanks


回答1:


Switching the view to "project" will give you full control over the file system for drag and drop purposes.




回答2:


Adding images to your project is quite easy and I think you are over reacting :). The resources directory in an android project are structured such that it allows for different images based on either size or what it is rendered as (icon or as is). For images that serve as icons, it is appropriate to place them in the resources/mip-map folder. For other images that won't be rendered as icons should be placed in the resources/drawable folder. Inside either of mip-map or drawable folder, you can have additional folders for different sizes of images ranging from mdpi to xxhdpi.

That said, you could decide to add images to your Android project by simply using Ctrl+C and going to the appropriate directory in AS and Ctrl+V (see karaokyo's answer on how to make these directories visible in AS). AS at times will try to auto detect the image size and suggest the appropriate folder. Otherwise you'll have to do this yourself.




回答3:


Drop any images into a res/drawable-mdpi folder. The plain res/drawable should work as well so no sure what you issue is there? There is no fancy or complicated way to add resources to your project. It should and is pretty simple.

You can learn more about the mdpi suffix and Android drawables on the following link: https://developer.android.com/guide/topics/resources/drawable-resource.html



来源:https://stackoverflow.com/questions/32663707/are-all-images-in-android-apps-considered-icons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!