Correct image drawable folder for Galaxy tab - android

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

Related

Android - Adding Images To Project

I am brand new to Android and I am using Eclipse ADT to create a simple application. This application has a button that changes it's background image based on user clicks.
I noticed that there are 4 folders for images in my project: drawable-hdpi, drawable-ldpi, drawable-mdpi, and drawable-xhdpi.
and I also noticed that the images that are in there currently (the launcher icon) are all different sizes.
Does this mean that I have to use some image editing software to create one image for each resolution for each of my images? Or (hopefully) is there a way to import an image and have this done for me automatically?
Thanks!
Images and other visual files are stored in one or more drawable directories. If only in one directory, Android will scale the image as needed. If more than one directory is used, Android will select the appropriately sized image.
drawable-ldpi - Low density images
drawable-mdpi - Medium density images
drawable-hdpi - High density images
drawable-xhdpi - Extra high density images (i.e. retina-like displays)
drawable-xxhdpi - Extra extra high density images (devices like Nexus 10, Samsung Galaxy S4, HTC One and Sony Xperia Z)
drawable-xxxhdpi - Triple extra high density images (Nexus 6 and 9)
(Side note: XML files can also be written and stored as drawables. These kinds of files can control when multiple images are to be used based on the state of a view, or other visual settings like gradients, borders, etc.)
So, what should you do?
For best results (from the Android developer docs):
To generate these images, you should start with your raw resource in vector format and generate the images for each density using the following size scale:
xxxhdpi: 4.0
xxhdpi: 3.0
xhdpi: 2.0
hdpi: 1.5
tvdpi: 1.33 (TVs only)
mdpi: 1.0 (baseline)
ldpi: 0.75
This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 133x133 for tvdpi, 100x100 for mdpi, and finally a 75x75 image for ldpi devices.
If you just want to use one image and let Android scale for you:
More than 75% of Android devices now have hdpi or greater resolutions, according to the Dashboard on the Android Developer site. So if you create one image at hdpi, for example, it will look perfect on about a third of devices, scale up for some, and scale down for about 25% of devices. In general I think you'd be better off scaling down than scaling up, too.
Does this mean that I have to use some image editing software to create one image for each resolution for each of my images? Or (hopefully) is there a way to import an image and have this done for me automatically?
If you already have high resolution sources (or vector graphic formats) of your images, you can use the Android Asset Studio to generate icons/images from your own source images for every density (minus xxhdpi). You can also create icons/images from default Android clipart, that can be themed for various versions of Android. This will save you some of the hassle of resizing and saving with an image editing tool.

How to set the drawable to for android app for multiple resolution?

I am developing android app which has lots of images. It's a korean app.
I want to support maximum number of resolution possible.
So I created 4 different folder(ldpi, mdpi, hdpi, xhdpi) for drawable as the google doc stated.
Now my problem is that my app work on all most all device perfectly but In korea there is device Pantech Vega LTE M which is giving lots of trouble
It's resolution is of xhdpi category but still in this device my app shows images from mdpi and it show bigger than it resolution. So half of the image is displays compressed.
So I am not getting how to set the drawables for this device. Do i need to add separate drawable folder to match this resolution.
If i changes the images in mdpi folder than it will create problem for other resolution.
Beside how many folder I need to add make my app compatible with every possible resolution available.
Thats because that device runs Android 2.3 Gingerbread where the X-Large configuration was yet not supported since that resolution was supported beginning with Adroid 3.0 afaik.
Edit:
Looks like the xhdpi was supported since API level 9, and the configuration specs from your device looks like a normal - large screen with xhdpi. So the only workaround that I could think of is creating those folders within your drawables.

Not drawing image/bitmap from correct drawable folder on canvas

I am new to android, and I'm trying to make a game that draws some image/bitmap. I have separate folders for drawable, however the emulator for tablet(wxga) is drawing the bitmap from drawable-mdpi even though I have proper images in drawable-xhdpi folder. What can the issue be? It would be great if you can point in the right direction.
Thanks in advance.
The emulator is doing the correct thing.
Have you read the official docs?
wxga is 1280×768 pixels, combined with a 10 inch screen that is actually mdpi. You need to specifcy a smaller screen size to increase the dpi.
On a side note: Most large android tablets have in fact mdpi resolution. But be careful: the Samsung Galaxy 10.1 Tab reports that it has hdpi even though the screen is technically mdpi.

How to Support Multiple Screens in Android without the need to Provide different bitmap drawables for different screen densities

I need to run my application on multiple devices with diffrent specs.
Now I'm trying to get it work on just two: Samsung Galaxy tab p100 and Galaxy tab 7.0 plus
the differnces I'm care about now are dpi,the first device is 240 dpi the second is 170 and the version the first runs 2.2 he later 3.2
first I put the Images on the hdpi folder images on 7.0 plus is smaller and ugly so I copied them to mdpi folder works fine but this would double the size of my APK.
Is there any way to make android auto fit Images without the need to copy Images?
If you want that images look fine in either the device you have to provide the same images for mdpi and hpdi at differente resolution (see Alternative drawables).
However if you put all you images in mdpi directory only, Android will scale theme for hpdi screens. Remember also you have to use dp and not px for all your dimensions (see Density independence).
You can also be interested in how Android pre-scale and auto-scale resources (see Additional Density Considerations). If you want to force auto-scale, you can add this line in your AndroidManifest.xml:
<supports-screens android:anyDensity="false"/>

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

Categories

Resources