This is a stupid question, so I'm sorry if it's been asked before but I cannot find the answer and I'm not even sure if it matters or not, but:
If I want to add Icons to my Android app, not just the App icon, but other icons and graphics. Which folder do I place them in, or how should I add them? I am using Android Studio to create my Android app and I know that the App's main icons (Launcher icons) are located in res/drawable-x but is this where I also put other graphics and icons too? I looked in the documentation and searched SO and Google but only found answers relating to App Launcher Icons.
You put all the icons and images res/drawable-xxx folders, e.g.:
/res/drawable-mdpi - resources for medium pixel density
/res/drawable-hdpi - resources for high pixel density
/res/drawable-port - resources just for portrait mode
More info here: Providing Resources
Got to
Project name --> res/drawable and paste all your icons
Yes res/drawable-x is where you have to add the images
The main folder is drawable but if you want app to support multiple density you can create multiple drawbles for different dpi and paste them to relative drawable folder
The hierarcy goes like this
res/
drawable/
icon.png
background.png
drawable-hdpi/
icon.png
background.png
there are more type of folders
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi // Added in API Level 8
drawable-nodpi
drawable-tvdpi // introduced in API 13
and also different drawable for different orientation you can add
drawable-land
drawable-port
Learn more here
provide alternative resources
Related
Clarification: Which image (downloaded from adobe xd ==> It gave 6 different size drawable folders) needs to be added to drawable folder in my android.
Here I have added drawable-hdpi folder image. But it looks blurred in my app.
Shall I need to add all the different sizes in my app?
You should look at the google documents.
I'm trying to figure out how to change the following image on start app with LibGdx framework.
I would like to customize it with my logo , but I can not find the reference in the solution .
Thanks for your help.
For IOS platform you should add in your ios/assets folder your own splash images in all resolutions with defined naming structure of Apple.
"Default.png" - 320x480 iphone3gs
"Default#2x.png" - 640x960 iphone4
"Default~ipad.png" - 768x1024 ipad
"Default#2x~ipad - 1536x2048 ipad retina
...etc
more details you can find here ..
Libgdx project for iOS displaying libgdx splash when compiling through robovm on simulator?
In windows explorer go to <path to your project>/desktop/assets
You'll see the default LibGDX image and here you can put all of your assets files (images, fonts, etc). You may also need to refresh your project folders in Android Studio so that the new image(s) will show up.
The java file that loads the image is under the core/src folder. Open this file and you will see where it loads the default image. Change the name of the image to the name of your new image and that should do it.
NOTE: If you are planning to build for android also, android will only see assets that are located in the android/assets folder (it's annoying, but this is the only way it works). I don't use Android Studio, but look up how to set the working directory for your desktop project to use the android/assets folder (instead of desktop/assets). Then put all of your images into the android/assets folder. This one took me a while to find out when I first started building for android. So if your desktop build works, but android doesn't...this is what you need to do to fix it. :)
1)for android, go to asset folder and paste your image
2)Refresh the asset folder
3) in your create method
//libgdx.png is the default image name that provided by the libgdx
texture = new Texture(Gdx.files.internal("data/libgdx.png"));
//in above code remove that "libgdx.png " and add your image name
Example:-
texture = new Texture(Gdx.files.internal("your image name.png"));
I'm using eclipse, and my app is at a point where there is a background, and when I run the emulator it doesn't have the background. It had done this before where I changed some text, but when I ran the emulator the text stayed the same. If someone could tell me what I am doing wrong then that would be great. Thanks.
I have noticed that changes made to xml files sometimes do not show up unless you do Project > Clean...
i tried the layout it works fine. You create a folder named as drawable similar to drawable-hdpi. Put your image inside the drawable folder. It work fine.
or
Blockquote
Another option about the problem is that you created you Emulator in such a way that the Android OS determines its screen as xhdpi. If an image is placed in drawable resource folder then Android will try to rescale it for the different resolutions. However if the image appears only in some of the resolution folders (lie drawable-ldpi etc) then the image will be served only in this resolutions.
Please, either create folder drawable-xhdpi and place the image also there, or create folder drawable and place the image there. It will be used for backup.
See the documentation about the image folders: http://developer.android.com/guide/practices/screens_support.html
In my drawable folders i have my icon image, and when testing i use it as a temp picture. I added 2 other images and a XML file and when ever the app loads the imageviews with the icon set to it has different images..
this is what it is meant to be be..
but this is what it is when i add other images to the drawable folder
And no, the names of the files are not the same.
The icon is called 'icon.png' - thats what it should be
instead it is 'ic_menu_compose.png' - a completely different name.
Also the files i'm adding are called:
'buttonnormal.png'
'buttonclicked.png'
and a XML file - 'buttonselector.xml'
Even if i dont use these images any where within my app the problem still occurs.
Any help would be much appreciated. Thanks! :)
[EDIT]
Are you building your app inbetween tests?
In eclipse: Project > Build Automatically (ticked) (this regenerates your R file)
Are you referencing the image by a raw ID?
setImageResource(324234234); WRONG
setImageResource(R.drawable.blah); Right
Are you using drawable image names that are already in use by the Android system: http://androiddrawableexplorer.appspot.com/
Personally I would rename that images from "ic_menu_compose" to something like "icon_menu_compose_overwritten" just incase it is clashing and screwing up your R file.
I'm having trouble getting a 160dpi, 480x800 emulator to display the contents of my main.xml in a layout-large folder. It seems to still be using the main.xml in my regular layout folder. Are there any common reasons it wouldn't be reading this file correctly?
To put it into context, I have a .png called "back_large" in my drawable-mdpi folder. I also have a .png called "back." Both are 160dpi, but "back_large" is roughly twice the size of "back." In the main.xml within the layout-large folder, I have an ImageView that points to "back_large". In the main.xml within the regular layout folder, I have an ImageView that points to "back." When I run both the Normal- and Large-sized 160dpi emulators, they both pick up "back," which leads me to believe layout-large is not being implemented properly. I just don't know why.
Thanks.
as far as I know layout-large resource qualifires are just used for the layout only and not for drawable images. put two images (back.png) with the same name in hdpi and mdpi folders. In you xml layouts both in layout normal/large folders just give reference to back.png. Android system will automatically detect the desired resources after checking the screen density and size for the target device during execution of application on device. .. Hope this helps.