Application doesn't see high density's images - android

My project contains three drawable's folders: drawable-hdpi, drawable-mdpi and drawable. I build it with android:minSdkVersion="3". When it runs on Andriod 1.6 or higher it always uses images from drawable-mdpi on high density screens.
How to fix this?

Have you tried setting android:anyDensity="true"?
http://developer.android.com/guide/topics/manifest/supports-screens-element.html

Related

What different drawable folders are for android XML

So I am learning how to program android apps, and have just barely started. Looking through the developers page I followed a tutorial to add a search bar in the menu. However, it asked to put an image in the res/drawable folder. Upon seeing all these options I just placed it in the first folder, drawable-hdpi, and the app worked. I was just wondering if anyone could explain what the difference in each folder is, and if the icon is placed in the correct folder (even if the app still runs). Whats the most optimal solution?
http://imgur.com/t2r6fS2
Android Tutorial: http://developer.android.com/training/basics/actionbar/adding-buttons.html
Edit: Wow! Thanks for all the responses. You guys are fantastic. I'll mark an answer as soon as it will let me.
The folder names need to be :
/drawable-ldpi For low density screens
/drawable-mdpi For medium density screens
/drawable-hdpi For high resolution screens
/drawable-xhdpi For extra high resolution screens
/drawable should be reserved for assets that you don't either care which device or for xml drawable assets
Then on top of that you can provide different resources based on configuration by using config qualifiers, you can read all about it here http://developer.android.com/guide/topics/resources/providing-resources.html
for instance, you can have high resolution assets for landscape with a folder
/drawable-land-hdpi
Hope that helps
Android devices comes with different screen sizes and different resolutions. To support your application's images with different device's screen size you need to put your image in their respective folders. Following are the screen size supported by Android devices
LDPI ( deprecated )
MDPI : 48x48 Pixel
HDPI : 72x72 Pixel
XHDPI : 96x96 Pixel
XXHDPI : 144x144 Pixel
TVDPI
You can create such sizes images by helping of this site Android Asset Studio
These different folders are for different screen sizes. Here is a link to the android notes, http://developer.android.com/guide/practices/screens_support.html .
In short the ldpi is for low resolution screens, mdpi for medium resolution and so on.
Android different Screen size with different resolutions:
- drawable-ldpi (it need resolution or ppi is ~120)
- drawable-mdpi (it need resolution or ppi is ~160)
- drawable-hdpi (it need resolution or ppi is ~240)
- drawable-xhdpi (it need resolution or ppi is ~320)
If you create big images but less ppi then it will go in this manner. So be aware about this.
this may help you ....
check out the answer in below link
What is the difference between "px", "dp", "dip" and "sp" on Android?

Correct image drawable folder for Galaxy tab

My Android application is not loading the correct graphic images when running on a Galaxy tab 1.0. They look blurry and slightly pixelated.
My guess is that it is loading the images from the mdpi folder, because the device density is 1.0, but they are small for the tablet screen.
What should I do in this case? I don't want to increase the size of the images in the mdpi folder, because I have tested the application in a fair quantity of emulators and devices and it worked well, but I still want a way of loading bigger images for the tablet.
The device model is GT-P7510 and Android version is 3.1. The density of the device is 1.0, which I got using the code:
getResources().getDisplayMetrics().density
I have different image sizes placed in the folders:
drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xhdpi
I am developing in API level 8, platform 2.2.
Thanks!
you should probably create
res/drawable-large-mdpi/
and put resources for large screens there. Instead of large you may evaluate to use other qualifiers, such as drawable-sw600dp,
see http://developer.android.com/guide/practices/screens_support.html and http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch

I am confused with drawable-hdpi and drawable-mdpi

i am attempting to get my android app to work on both phone type devices and tablets. for the layouts i have layout-normal and layout-large and i place my xml files inside each and it seems to select the correct one for each device (layout-normal for phones and layout-large for tablets).
however the problem arises for the drawable folders. i have drawable-hdpi, drawable-mdpi and drawable-ldpi. the tablet is taking its images from the drawable-mdpi, and the phone is taking its images from the drawable-hdpi. from the reading i have been doing this seems to be backwards??? this seems to happen on both the emulator and real devices, could i be doing something wrong? am i mixing something up?
Clayton,
drawable-hdpi and drawable-mdpi is not related to the size of the screen itself, but to the resolution of the display.
It's probably easy to think in terms of the iPhone 3GS and 4 for this (bear with me please). The 4 has retina display, hence a much higher resolution. Using the same sprites you'd use with the 3GS would result in a blurry display.
Android phones are, if anything, much more diverse in terms of screen options.
If you want to be able to aim different layouts at different resolutions, please try putting the layouts into /layout-xlarge, /layout-large, etc...
You can find more here:
http://developer.android.com/guide/practices/screens_support.html
There are some changes that you can see for Android 3.2 and above:
Beginning with Android 3.2 (API level 13), the above size groups are
deprecated and you should instead use the swdp configuration
qualifier to define the smallest available width required by your
layout resources. For example, if your multi-pane tablet layout
requires at least 600dp of screen width, you should place it in
layout-sw600dp/. Using the new techniques for declaring layout
resources is discussed further in the section about Declaring Tablet
Layouts for Android 3.2.
ldpi, mdpi, and hdpi refer to pixel density, not screen size.
The accepted answer does not address a serious problem: if you have many drawables, you end up with an unnecessarily big apk file because of resource duplicating. The only solution for that is the resource alias option described here:
http://blog.evendanan.net/2011/03/Android-resources-and-device-fragmentation
Edit: I just beheld that OP didn't realize that most phones have hdpi density, while most tablets have mdpi density. At the same time the tablets mostly have higher resolution. Hence Android will use smaller pictures for higher resolution.
You can overcome this only by using vector images or using the methods described in the accepted answer and in my answer.
drawable-hdpi - application use this drawable images when the device has high pixel density
drawable-mdpi - application use this drawable images when the device has medium pixel density
drawable-ldpi.-application use this drawable images when the device has low pixel density

Having 1 drawable folder instead of 3 in eclipse

Hey all, right now I have a drawable-hdpi, drawable-mdpi, drawable-ldpi folder inside my res directory... I hear that android now filters out applications based on screen size and density. All of my images are inside the drawable-hdpi folder. Should I make just 1 folder called "drawable" and delete the other 3? Or should I convert all the images to the proper size and place them inside all three folders?
Leave the folders as they are and put your medium density images in drawable-mdpi and hign density images in drawable-hdpi folder. I would leave the small density screens and let android scale them. But if you are worried about small density then put those in the drawable-ldpi directory too.
There are only a very few devices that support small screens.
Now for supporting multiple screens you need to make some changes in your manifest. Here is the explanation of what developers need to do to support multiple screens.
A note of caution if you are supporting 1.5 devices. In this case put all the images in your drawable-mdpi into drawable folder. That is because 1.5 devices do not support multiple screens and they recognize images in drawable folder.

different drawable resolutions

I want to deploy my application on different screen sizes using the 1.6 feature.
I exported the drawable resources with different resolutions in drawable-ldpi, drawable-mdpi and drawable-hdpi folders.
On android 1.6 and 2.0 everything looks good.
My problem is that on 1.5 the drawable-ldpi resources are used instead of drawable or drawable-mdpi ... the application still works but it renders the images scaled and the image quality is lost.
How can I configure the application so that on 1.5 the only the drawable-mdi folder will be used?
I'd like to keep the apilevel to 3 so that the same apk will run on 1.5, 1.6 and 2.0.
Try adding -v4 to your -ldpi, -mdpi, and -hdpi directory names, and having a base res/drawable/ for use by Android 1.5.

Categories

Resources