I'm writing an Android app and have read up everything I can find on fragmentation and handling multiple screens, particularly from the official Android documentation.
I understand different screen densities utilize the various folders (mdpi, hdpi etc.) for images of varying sizes, and different screen sizes can utilize different layouts by defining them in res/layout-sw600dp layout-sw720dp etc. which all makes sense.
However, when developing my app my primary test device was a HTC Desire X phone 400x800 with 240dpi density and all looks well. I then tested it on a Prestigio Multipad 8.0 tablet and this is where I'm getting confused. The tablet has a screen size of 786x1232 BUT the screen density is only 160dpi. Owing to the fact that the screen density on the tablet is smaller, Android therefore uses the images in the mdpi folder for the tablet, and the slightly bigger ones in the hdpi folder for the phone! This therefore results in images way too small on the tablet.
I don't need to edit the layout for the tablet so the sw720dpi folders aren't a help.
What am I missing or not understanding properly here? How can I make my images scale up for the bigger, lower density tablet screen?
OK, I figured this out eventually. My mistake was I didn't realize drawables work exactly the same as layouts in that I could have a drawable-sw720dp folder which Android fetches the images from in the case of a screen with at least 720pixels of width. For completeness in the scenario I described I could have a drawable-sw720dp-mdpi folder in which to store my images.
I had an additional issue then whereby I had 2 copies of the same image in different drawable folders but I discovered you can reference images using an alias just like layouts. Details of how to do that can be found here.
I'm trying to create an android app optimized for Galaxy S2 and Galaxy S3.
I created the images for Galaxy S3 and I put them in the xhdpi folder.
After that I reduce the images 75% and put them in the folder for hdpi (according to Android Guidelines for multi-density).
The problem is that the S2 do not only have lower density also the screen is smaller so the images resized only 75% are too big to be used.
Example: a full width image in Galaxy S3 will be 720px wide, the 75% is 540px that is bigger than 480px wide that I need for full width in Galaxy S2.
The problem is that I have at the same time 2 different densities and 2 different screen sizes.
How can I handle multidensity + multi sreen size?
Should I do it only creating the specific images with the specific sizes for G2 and G3 or there is a way (by code) to tell the phone to auto adjust the image to a certain size (for example I provide an image that is originally width 540px but I tell the phone to rescale it to 480px to be adjusted full width in Galaxy 2.
I'm clear that the images for G3 must be xhdpi and G2 hdpi, but the question is more about how to handle the different screen sizes wisely.
Thanks,
David
I tested my app on Galaxy tab 10.1 and found something strange.
I use a large image as title of app created for large screen. But when checked it, image quality is lowered.
I never touched image like resizing. Image resolution is fit so there is nothing to change.
When viewing same image on gallary, it seems almost same.
Only in app, image is deteriorated.
I using image folder drawble-xhdpi and layout folder layout-xlarge.
Is there something more i should check?
You should check what density the device you're testing on actually is. The Galaxy Tab 10.1 is an mdpi device, not an xhdpi device. Also, it's recommended not to use the large and xlarge qualifiers, and instead to use the smallest-width qualifiers (e.g. sw600dp for 7", sw720dp for 10").
What simulator resolution i should keep when developing application for Samsung galaxy s2 and galaxy s3 ?
What i found that samsung galaxy s2 has 480x800 resolution and s3 has 1280x720 resolution so what i have understood up till now that I should ask my graphics designer to provide me hdpi graphics that contain 480x800 background images and to implement same background image in galaxy s3 mobile, I will use image of size 1280x720 and put in xhdpi folder so that it can work on s3.
The background image is something which covers whole available area for mobile app. so am i right ??
You will need to create several emulators or get various devices.
There are some pretty important ones, so generally you need to make sure you have:
ldpi, mdpi, hdpi, xhdpi
and
small, medium, large, xlarge
Some people choose to exclude certain sizes (like small and ldpi) but htat's up to you,
if you go with some or all of the following, it should be a good start:
480x320 (SE Mini 10), 480x800 (GS2, Desire, etc), 1280x720 (GS3, Galaxy Nexus etc), 1280x800 (Note, Xoom, various other tablets)
HTC ChaCha (because it's landscape default)
You need to make sure you create resources in the relevant folders for each density, usually, I tend to ignore ldpi and just put resources in:
mdpi,hdpi and xhdpi (mdpi will be scaled down for ldpi devices,
automatically)
You may also need to create various portrait and landscape layouts in different sizes.
Reading this page provides most of the necessary information:
http://developer.android.com/guide/practices/screens_support.html
This page also contains important information regarding size distribution and popularity that is constantly up to date:
Android Stats
One thing that Android does for you is that it manages resolution. If you use the proper size formats (dp, sp, etc), your layout will scale to almost all resolutions. If you place images in the proper drawable folders (hdpi, ldpi, mdpi, etc), the OS will also swap those out as necessary.
Also, the emulator should handle resolutions for specific devices, if I recall correctly.
Desing lazout in smart way! Usualy it means don't put to mutch content in one layout.
Make sure that evrything looks good on smallest size and bigest size. It is better to treat tablets separetly. Read how providing alternative resources works, you can build sepereate layouts for each screen size.
Check if the hardware is available on that device before using it. hasSystemFeature() can be used for checking.
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.