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.
Related
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
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
This is a scenario. There are folders:
drawable
drawable-ldpi
drawable-mdpi
drawable-hdpi
draawble-xhdpi
An image (usually background, but not bound to such images only) is located in /res/drawable only.
I test the app on Galaxy S3 and the background is displayed properly. I test on HTC One X and background image is not being displayed.
If I copy the image from /res/drawable to /res/drawable-xhdpi, the One X will display image.
Thinking logically, this should not be happening, right?! If there is no image in drawable-xhdpi, then Android should look it into other folders until it reaches the default one /res/drawable and it should pull it from there.
Why is this not happening on some mobiles?
PS. I noticed the same issue with some tablets, but I cannot remember now which ones.
PPS. I mentioned background image here, but the issue is not bound to it. It also happens with other images. I am aware that xhdpi mobiles have issues with large images and I would not like you to think that the issue was with too large background image. It also happens with other images of "normal" size.
why do you want to put an image file into the drawable folder ?
according to tips i've read over the internet , you should not put images files in the drawable folder .
in the drawable folder you put only xml type drawables.
if you want to put an image file , put it in any of the following folders (or add an additional qualifier for them , or use other qualifiers ) :
drawable-nodpi (only for images that you don't know what should be their size)
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-tvdpi
images that are put into the drawable folder are treated as default , which is mdpi . so if you want to keep the file in the same screen density category , put it into the drawable-mdpi folder.
another reason for not putting an image into the drawable folder is that android will automatically convert the file to 16 bit image for some devices (like the samsung galaxy s) , which will make the image look awful on some cases.
here's a link that explains this issue .
I made a project with a drawable that is only in the "res/drawable" folder, tested it on my One X, and confirmed the image is displayed:
https://github.com/lnanek/Misc/tree/master/TestOneXDrawableFolder
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:src="#drawable/drawableonly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
Resources:
res
res/drawable
res/drawable/drawableonly.png
res/drawable-hdpi
res/drawable-hdpi/ic_launcher.png
res/drawable-ldpi
res/drawable-mdpi
res/drawable-mdpi/ic_launcher.png
res/drawable-xhdpi
res/drawable-xhdpi/ic_launcher.png
res/layout
res/layout/activity_main.xml
res/menu
res/menu/activity_main.xml
res/values
res/values/strings.xml
res/values/styles.xml
res/values-v11
res/values-v11/styles.xml
res/values-v14
res/values-v14/styles.xml
You can try to figure out what you are doing different that might be triggering some other behavior. Keep in mind that having a "drawable" folder and a "drawable-mdpi" folder is a little odd, because the drawable folder is mdpi density by default. It may be not be deterministic which of those two will get used. I know using a density specifier does automatically append a -v4 in modern build tools to fix problems with Android 1.5 not understanding these specifiers and handling them correctly, so drawable-mdpi-v4 might be considered to have more specifiers and match in precedence compare to drawable. Both folders have a mdpi density class anyway, however, so keep in mind your drawable from either folder will be scaled up automatically if used from there.
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.