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
Related
I am working on Andoid application for mobile only(Not for Tablet). So I am going to tell designer to make PSD for android screens. Generally I tell my designer for making application design on these three sizes and I use dimen to adjust layout for other devices:
320* 480 (and I put these images into mdpi folder)
480*800 (I put these images into hdpi folder)
800*1280 (I put these images into xhdpi folder)
So I want to know what size of PSD should I made from my designer.I am asking about complete screen size.
//For Designer
start design PSD file from 100% i.e design from XHDPI then need to downscale it to
75% for HDPI
and 50% for MDPI
//For Developer
start design for MDPI first then place drawables in appropriate folder
Baseline phone mdpi 320x480
from that you can increase you drawables as 1.5 for HDPI and 2 for XHDPI
Developer keep in mind while designing layout ref best Practices
1. Use wrap_content, fill_parent, or dp units when specifying
dimensions in an XML layout file.
2. Do not use hard coded pixel values in your application code
3. Do not use AbsoluteLayout (it's deprecated)
4. Supply alternative bitmap drawables for different screen densities
Different screen pixel ratio :-
ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3
so lets take an image with about the size of 100X100:
for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300
http://developer.android.com/guide/practices/screens_support.html
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
I'm a little confused about how to determine which phones support what layout types. I've done some research but haven't found a satisfying answer.
For example, I've found the below guide:
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
However, I still have some concerns:
Samsung grand (480*800) and HTC wild fire S (320*480) both support MDPI. These screens have very different resolutions, yet have the same layout type?
Galaxy note 2 (1280*720) support HDPI. If HD (720p) is only HDPI, when what device/resolution supports XHDPI?
I've already asked a related question here: How to set layout on 7" two different tablet?.
My most important question, however, is this: How do I know which devices or screen resolutions support each layout type?
Android treats mdpi (160 pixels/inch) as the base density. So for mdpi devices, 1 dp = 1 pixel. At higher densities, there are more pixels per inch (240 for hdpi, 320 for xhdpi).
AutoMatic Scaling by Android itself:
Android attempts to make graphic images occupy the same physical dimensions on the screen regardless of the device pixel density. So if all it finds is an mdpi resource, and the device is hdpi, it will scale the graphic by 240/160 = 150%, and it will double the size of the graphic for xhdpi.
Using different versions of graphics :
If you don't want this automatic scaling (which can make graphics look poor), you can simply supply your own version of graphic resources for use at higher densities. These graphics should be of the same size that Android would scale an mdpi resource.
Note : the pixels/inch that was stored in the image file has nothing to do with this. It's all based on where you put the graphics files in the resources directory for your project. Any graphics placed in res/drawable are assumed to be properly sized for mdpi displays, as are graphics placed in res/drawable-mdpi. Image files that it finds in res/drawable-hdpi are assumed to be properly sized for hdpi displays, etc. When your program runs on a particular device, Android will first look for a graphic that matches the display density of that device. If it does not find one but instead finds one for a different density, it will use that and automatically scale the image based on the above rules.
As the ldpi, mdpi and hdpi refer to screen density, which means how much pixels can fit into a single inch.
the ratio in pixels between them is:
ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3
so lets take an image with about the size of 100X100:
for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300
this way, for screens with the same size but different DPI, all the images seem the same size on screen.
look into these details: android manages all this by itself, you just have to provide layouts and images in relative folders
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
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
I am designing a background for my app for all Android devices.
I was thinking what would be the size of the image in pixels?
From the developer site I found the following equation
px = dp * (dpi / 160)
Then, px depends on two variables.
First, dp, and we have
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
Second, dpi and we have
low-density (ldpi) screens (~120dpi).
medium-density (mdpi) screens (~160dpi).
high-density (hdpi) screens (~240dpi).
extra high-density (xhdpi) screens (~320dpi).
So where should I put my drawables in the Screen characteristic? I mean should I use "size" or "Density". If I classify my images using the "size" "dp", what is the dpi for these images?
and if I classify my images using the "density" "dpi", what is the dp for these images?
I am confused on how to finally size my images. Also, Maybe you can have a medium density screen with a large screen size, right?
There are many many different resolutions out there. For instance there could be 4 different devices which are:
640 px x 480 px
The difference is, some of these devices are mdpi, some are hdpi, xhdpi etc. meaning they could be described as "large", "medium" or "xlarge" screen types.
So, for an mdpi device which is 640x480dp the background would be 640x480px however, a device which is 640x480dp and hdpi would need a background which is 960x720px, you'll notice they're the same size "bucket" but have different densities and therefore different resolutions.
So, if you just want your background to fit as well as can be expected you'll need:
large-xhdpi
large-tvdpi
large-hdpi
large-mdpi
large-ldpi
(then the same for normal)
normal-xhdpi
normal-tvdpi
etc etc etc.
You're best bet however is to use an image which can stretch, a shape, tile or can be converted to a 9-patch because it would be a pain in the rump to make every background available for every device. If you were going to do it I would look up a resource descrivbing every screen dimension on the market currently and setting it via programmatic methods.
I am following this tutorial link
There three types of 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
But there are three folders
drawabale-hdpi
drawabale-mdpi
drawabale-ldpi
I placed images of xlarge in hdpi
that of large in mdpi
and that of normal in ldpi
but where to place the images of small screens?
Sorry for bad english
For example, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
and Screen Sizes.
I hope this help.
hdpi, mdpi and ldpi refer to the screen density in dots-per-inch. This is completely separate from the screen size (small, large, etc).
You can have large screen with low density, or a small screen with high density, etc.
You can cater for different screen sizes by putting different layout resources in res/layout-small, res/layout-large, etc.
These are two different things - hdpi/mdpi/ldpi are screen densities (i.e., how many pixels per square centimeter) while xlarge/large/normal/small are screen sizes (the physical dimensions of the screen). So the small screen images would go in drawable-small, normal in drawable-normal, etc.
There's a lot more info about this stuff on the Android developer website.
Screen size has no relation with density. xlarge screen does not mean it has hdpi density. For example tab like galaxy 10.1 pr motorola xoom has xlarge screen but mdpi density so for them you make a separate folder drawable-xlarge. and for this you have to add android:xlargeScreens="true" in manifest.
And devices like galaxy s2 or htc desire has hdpi density. Devices with small screens like galaxy pop are mostly have ldpi density, normal screens like galaxy ace are mostly mdpi devices and devices with large screens like galaxy s2 are mostly hdpi devices, and some devices like tab P1000 have large screens but mdpi density and for them you have to make folder drawable-large-mdpi.