Screen size and dpi of bitmaps - android

I found two approximations of how developer should support bitmaps for different screen sizes. One is this:
ldpi low density 120 dpi
mdpi medium density 160 dpi
hdpi high density 240 dpi
xhdpi extra high density 320 dpi
The other is this:
xhdpi: 2.0
hdpi: 1.5
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, 100x100 for
mdpi and finally a 75x75 image for ldpi devices
Does it mean that If I take as a baseline 640x360, I have to make following 4 groups of images:
1) ldpi - size 480x270 pixels and density 120 dpi
2) mdpi - size 640x360 pixels and density 160 dpi
3) hdpi - size 960x540 pixels and density 240 dpi
4) xhdpi - size 1280x720 pixels and density 320 dpi

You are misunderstanding.
The documentation is not saying different things. The second part you reference is telling you how much bigger an image is in relation to the base density of mdpi
e.g xhdpi fits 2x the amount of horizontal and vertical pixels into the same space that mdpi would.
mdpi = 160 dpi (scale factor 1)
xhdpi = 320 dpi (x2 twice as dense as mdpi therefore an image in this folder needs to be twice as high and twice as wide as its mdpi counterpart to appear the same size on an xhdpi screen)

Related

Android image size confusion

I'm very confused about making drawables for Android.
Let's say I want to make a big image that will fill 30% of the screen, or a certain amount of dp, like 300dp.
What size should that image be in pixels for each screen density, and in what dpi should I save it in?
For 300dp, you need:
300px for mdpi (1x)
450px for hdpi (1.5x)
600px for xhdpi (2x)
900px for xxhdpi (3x)
1200px for xxxhdpi (4x)
https://developer.android.com/guide/practices/screens_support.html
ldpi - 0.75 * mdpi ,
mdpi - 1 * mdpi ,
hdpi - 1.5 * mdpi ,
xhdpi - 2 * mdpi ,
xxhdpi - 3 * mdpi ,
xxxhdpi - 4 * hdpi ,
so if you want to generate for mdpi screen to be 300dp the image should be resized according to the above calculation

Image resolution for mdpi, hdpi, xhdpi and xxhdpi

I have a background for my app in resolutions 720x1280 pixels, 1080x1920 pixels and 1440x2560 pixels.
In which folders (mdpi, hdpi, xhdpi and xxhdpi) should I put each background?
Please read the Android Documentation regarding screen sizes.
From a base image size, there is a 3:4:6:8:12:16 scaling ratio in drawable size by DPI.
LDPI - 0.75x
MDPI - Original size // means 1.0x here
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
For example, 100x100px image on a MDPI will be the same size of a 200x200px on a XHDPI screen.
Require Screen sizes for splash :
LDPI: Portrait: 200 X 320px
MDPI: Portrait: 320 X 480px
HDPI: Portrait: 480 X 800px
XHDPI: Portrait: 720 X 1280px
XXHDPI: Portrait: 960 X 1600px
XXXHDPI: Portrait: 1440 x 2560px
Require icon Sizes for App :
http://iconhandbook.co.uk/reference/chart/android/
DP size of any device is (actual resolution / density conversion factor).
Density conversion factor for density buckets are as follows:
ldpi: 0.75
mdpi: 1.0 (base density)
hdpi: 1.5
xhdpi: 2.0
xxhdpi: 3.0
xxxhdpi: 4.0
Examples of resolution/density conversion to DP:
ldpi device of 240 X 320 px will be of 320 X 426.66 DP. 240 / 0.75 = 320 dp 320 / 0.75 = 426.66 dp
xxhdpi device of 1080 x 1920 pixels (Samsung S4, S5) will be of 360 X 640 dp. 1080 / 3 = 360 dp 1920 / 3 = 640 dp
This image show more:
For more details about DIP read here.
Check the image above I hope it will help someone.
Link to the whole article itself
Your inputs lack one important information of device dimension.
Suppose now popular phone is 6 inch(the diagonal of the display), you will have following results
DPI: Dots per inch - number of dots(pixels) per segment(line) of 1 inch.
DPI=Diagonal/Device size
Scaling Ratio= Real DPI/160.
160 is basic density (MHDPI)
DP: (Density-independent Pixel)=1/160 inch, think of it as a measurement unit
in order to know the phone resolution simply create a image with label mdpi, hdpi, xhdpi and xxhdpi. put these images in respective folder like mdpi, hdpi, xhdpi and xxhdpi. create a image view in layout and load this image.
the phone will load the respective image from a specific folder. by this you will get the phone resolution or *dpi it is using.

Need advice for Android multiple resolution design

For example, I'd like to show an image in screen. Here are the size and dpi:
LDPI - 0.75x 75x75 120 dpi
MDPI - Original size 100x100 160 dpi
HDPI - 1.5x 150x150 240 dpi
XHDPI - 2.0x 200x200 320 dpi
XXHDPI - 3x 300x300 480 dpi
XXXHDPI - 4.0x 400x400 640 dpi
But the display for two devices is not what I want.
The first device is 480x800, 240 dpi. The second device is 800x1280, 213 dpi.The bigger screen has lower dpi. I need some advices on how to handle this case? Thanks
What I see is that your first device is a mobile while the second is a tablet. So you can provide alternate layout files for mobile's and tablets. See supporting multiple screens for more information. For this case for mobile you can use layout-sw720dp folder and for the bigger tablet screen. As for the images your current settings above will work great.

Large - Normal in Multiple Screens Android

Through as Supporting Different Densities , there are 4 types of screens :
xhdpi
hdpi
mdpi
ldpi
I want to know WHAT IS EXACTLY SCREEN SIZE ( in PIXEL ) of these ? :
normal-xhdpi large-xhdpi
normal-hdpi large-hdpi
normal-mdpi large-mdpi
These screen sizes is given by Eclipse :
xhdpi : 768 x 1280
2560 x 1600
720 x 1280
hdpi : 480 x 800
480 x 854
mdpi : 1280 x 800
1024 x 600
480 x 854
480 x 800
320 x 480
See you are mixing the concepts. small,medium,large and xlarge are screen sizes whereas ldpi,mdpi,hdpi , xhdpi,nodpi and tvdpi are screen densities
According to Android Developer's website
SIZE
small - Resources for small size screens.
normal - Resources for normal size screens. (This is the baseline size.)
large - Resources for large size screens.
xlarge - Resources for extra large size screens.
Density
ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi).
(This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
nodpi Resources for all densities. These are density-independent resources.
The system does not scale resources tagged with this qualifier,
regardless of the current screen's density.
tvdpi Resources for screens somewhere between mdpi and hdpi; approximately
213dpi. This is not considered a "primary" density group. It is mostly
intended for televisions and most apps shouldn't need it—providing mdpi and
hdpi resources is sufficient for most apps and the system will scale them as
appropriate. If you find it necessary to provide tvdpi resources,
you should size them at a factor of 1.33*mdpi.
For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
Now the minimum resolution of each size is defined below
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
Also from the android Docs
The conversion of dp units to screen pixels is simple: pixels = dps * (density / 160). For example, on 240 dpi screen, 1 dp would equal 1.5 physical pixels. Using dp units to define your application’s UI is highly recommended, as a way of ensuring proper display of your UI on different screens.
Which means two different devices with different densities can have the same number of dp but not same pixels.
This Formula worked for me to get the screen size and convert them into pixels :
float scale = getBaseContext().getResources().getDisplayMetrics().density;
int pixels = (int) (120 * scale + 0.5f);

How do I prepare images for all the Android resolutions?

In iOS preparing graphics is simple. There are either a normal image (height x width) or a retina image which is #2x (2 times height x 2 times width).
However, since I'm new to Android, I see a ton of drawable-* folders in Eclipse where the * can be "hdpi" or "ldpi" or "mdpi" or "xhdpi" or "xxhdpi". Can someone very clearly and simply list for me what I must do to satisfy each of the display possibilities so my images will look right in each instance? I'm envisioning an answer will be a bullet list with each "*" listed and a sub-bullet list including the things that must be done.
I'd also really enjoy an answer that would start with the highest density and greatest dimension image and working down since I'll be creating in Photoshop and will be reducing quality from a master image.
i got this off of this site a while back, it still comes in handy
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
Generalised Dpi values for screens:
ldpi Resources for low-density (ldpi) screens (~120dpi)
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
Therefore generalised size of your resources (assuming they are full screen):
ldpi
Vertical = 426 * 120 / 160 = 319.5px
Horizontal = 320 * 120 / 160 = 240px
mdpi
Vertical = 470 * 160 / 160 = 470px
Horizontal = 320 * 160 / 160 = 320px
hdpi
Vertical = 640 * 240 / 160 = 960px
Horizontal = 480 * 240 / 160 = 720px
xhdpi
Vertical = 960 * 320 / 160 = 1920px
Horizontal = 720 * 320 / 160 = 1440px
px = dp*dpi/160
In Android Studio just go to File -> New -> Image Asset and create your images right out of the IDE.
On Android we usually handle image sizes in units of "dp" or "dip" which stands for device independent pixel. 1 dip = 1 pixel, on a mdpi screen. There are loads of devices out there with different screen densities, not just normal and retina, so there are multiple DPI buckets a device's screen may fall into:
ldpi (low dpi): around 120 dpi
mdpi (medium dpi): around 160 dpi
hdpi (high dpi): around 240 dpi
xhdpi (xtra high dpi): around 320 dpi
Note that these are buckets, so a device with a 170 dpi screen will count as an mdpi device.
Let's say that you have a vector based image in PS and you need to create an image resource for Android and you'd like to support all these screen densities. Let's say that image needs to be 100x100 dip large. So you create a 100x100 pixel version for mdpi, a 150x150 pixel version for hdpi, 200x200 for xhdpi, and 75x75 for ldpi. You can think of "mdpi - xhdpi" on Android as "normal - retina" on iOS.
As for the larges image size that you can use, I really can't say. There's no hard limit as far as I know, but the device obviously won't be able to load a 20000x20000 bitmap into memory without downsampling because of heap limits.
There is an online tool for that Android Asset Studio
And also there is File|New|Android Icon Set in Eclipse

Categories

Resources