Ok, so I find generally that everyone will reference the Android Dev when the question is pretaining to background Images in an Android application. All I can find in the the Dev article is:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
Does that mean I just convert dp tp pixels when I am creating each seperate drawable?
For instance 960dp is 1920px.
You could have any of the next solutions:
really put each image in each density bucket. this will result in better precision of the pixels, but will make your app larger.
put one large image into either drawable-xhdpi or drawable-xxhdpi folders. rest of the densities will automatically adapt.
if the background is simple enough, use either a 9-patch or an xml drawable.
in fact, those solutions are valid for each image you face, and not just backgrounds.
in any case, do remember that having a background for the entire screen takes a lot of memory (can reach 3 MB for just a background, depends on the screen resolution).
Related
I am having the following specification images,
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
Both in portrait and landscape. These are stretched in Tablet. But working fine in mobile. I am handling the configuration changes using the onConfigurationChanged() override method. Is any other way for giving the images for Android application. I reffered the following link for screen sizes. http://developer.android.com/guide/practices/screens_support.html
you can use drawable-large for tab
Following crocboy link is correct, and i suggest you to try including more buckets on your app. For example, in my applications i use also this:
drawable-sw600dp-mdpi
drawable-sw720dp-mdpi
In this buckets, put images that match tablets screen, for example in drawable-sw600dp-mdpi insert a background with this size 1280x800 and for drawable-sw720dp-mdpi a background with this size 1920x1200.
It's quite difficult to decide wich tablet to target, because we have different screen size.
EDIT
"application have to support all devices. So, the drawable folder images also have to support for all the devices. How to achieve this?".
Basically Android create this 4 folder for drawable:
drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xhdpi
(To be picky, low drawable-ldpi is not quite used, because small device are loosing appeal)But due to density and screen size you can have:
drawable-large-mdpi
drawable-large-hdpi
drawable-large-xhpdi
drawable-xlarge-hdpi
drawable-xlarge-mdpi
And so on with various combination! If you are looking for image perfection (like my graphics collegue, wich is an iOS psychopath) you have to create images for every type of screen, and put it on relative drawable bucket.
In the same link ("How to Support Multiple Screens"), they tell you how to create seperate drawable folders for each resolution - such as drawable-hdpi. When the system detects a high-resolution screen, it takes drawables from the high-density folders. You can also do the same with layout folders. If it's a low-resolution screen, it uses only images from the low-resolution images folder, drawable-ldpi. Here is also a good article article about how Android picks images from these folders.
In my App I found that the background used is occupying a large memory space. I planned to keep different size image for different devices of varying size. Now there are 5 folders in my drawables.
drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xhdpi
drawable-xxhdpi
I need to create the background image which is going to occupy the entire screen. The quality should not be compromised. Based on the above scenario can you please let me know the right size of the image for 5 different folders.
Thanks in advance
If "quality should not be compromised" is absolutely crucial, then there are much more different dimensions for you to support. There always be some size or aspect ratio differences on devices with similar size, for example 800x480 and 848x480 or 1280x720 and 1280x800
If you accept minor distortion, then you may use following sizes, take from the link in first comment:
1920dp x 1080dp
960dp x 720dp
640dp x 480dp
470dp x 320dp
426dp x 320dp
as per android developers docs, 96 X 96 px is the icon size required for high density screens . Can i use the same size icon for all the screens? or I have to provide different sizes for different screens like ldpi, mdpi . Also, png is the only format accepted or any format accepted ?
Also for splash screen, 1440 X 1080 px is for xlarge screens, so can I use this single image for all the other screens (like large, normal and small) Or do i have to provide separate images for all the screens ? Also, what formats are supported?
Please read about how to support multiple screens
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
You have to use separate images and separate layouts to handle different screen sizes. Otherwise for xlarge screens the image may be fine but for small screens it will get cropped. Same will happen with layouts. So for best programming experience please use separate files. Android supports files other than .png as well.
If you use one icon then Android system will stretch and set it for all other resolution. problem is your icon is stretch for large screen. then, it might causes to appearance of the application. so you have to think this.
if you use each icon for each display size, it may causes to apk file size. this is the same thing about other images that adding for different display sizes.so you have to consider this.
most of the time you can manage this with 9patch images to avoid this.
with my experience, I have notice that avoiding images that have circles makes not to use different images for different screen sizes.then you can manage it with less images.When they are stretched circles become ellipse.
I think now you have idea.
Thais is what I have done. I try to support this screen sizes:
xlarge screens 640dp x 960dp
large screens 480dp x 800dp
normal screens 320dp x 400dp
small screens 240dp x 400dp
So I create etc. background images with that sizes (640dp x 960dp, 480dp x 800dp, 320dp x 400dp and 240 x 400). I put images in folders drawabale-xhdpi, drawabale-hdpi, drawabale-mdpi and drawabale-ldpi.
When I have xlarge screen with hdpi density (it use images from hdpi folder), graphic is bad (images are not large enough). So how to use that xlarge image when I have hdpi density. Do I have to create more images and put them in some places? This is a game, I draw all in canvas, don't use layouts for drawing images.
Thanks.
You can add new drawables in a drawable-xlarge-hdpi folder
use this path to save your image
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Check this Supporting Multiple Screens for more clarifications of multiple screen support.
Take a look at this link - Providing Resources
You can have an image in drawable-xlarge-hdpi folder
always use relative layouts to support multiple screens. see here Android layouts for same density different diagonal length
As per "android multiple screen design":
"As you design your UI for different screen sizes, you'll discover that each design requires a minimum amount of space. So, each generalized screen size above has an associated minimum resolution that's defined by the system. These minimum sizes are in "dp" units—the same units you should use when defining your layouts—which allows the system to avoid worrying about changes in screen density.
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp"
DisplayMetrics class gives me access to actual width and height of the screen. However is the above table available programmatically. Or do I need to store these values as constants in my app. The second option seems hacky.
Your problem is that you try to make a fixed design for x known resolutions whereas Android's Framework is based on the idea that you don't know in advance the exact dimensions of the device your app will be running on. And if you look at the Android market, that's a good assumption to make.
If you make good uses of :
-selectors like "sw600dp"(7" tablet)
-nine-patchs (stretchables assets)
-dimensions in dip for things that need to have a fixed size (for example a button needs to be 48dp at least in order to be big enough)
you can make very good designs that adapt to all form factors from 2" phones to 10" tablets.