Android - Deciding image sizes for app - android

Hello there fellow programmers!
Currently I'm having problem with deciding size of an image in Android. I've read about it in Screen Support Guide but I'm still confused about dpi and screen sizes. I have a 140x150 image in 72 dpi. If I resize it to 160 dpi (mdpi) it'll turn into a huge image. I focused on smartphones only but now I'm considering tab. Should I have made a 160 dpi image with the same size of 140 x 150, or having a huge 160dpi image is normal?
Update 7th Jan :
Found an interesting plugin in Photoshop called Cut & Slice, going to try it now.

A pixel is just a square.
A dpi (dot per inch) corresponds to the resolution of the image.
The more pixels per inch, the sharper an image will appear because of the size of each pixel.
The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160)
You should get two images with different size for different devices to improve the quality of your pictures and, when it's for webapps, the loading speed of your pages.
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

Related

how to design any screen size and - density in Android(Multi screen for mobiles in Android)

How to handle design in multi screen for mobiles in Android without using dimention in values folder.
My application it's support all android mobiles, and I had a problem with the design, because I'm using dimen in values folder to handle it.
So please anyone can help me to handle this problem without using the dimention.
layout compatibility is very important part of any project
sorry but you have to use dimens for handle this problem.
and i think best way for design is use density.
you can use dimens-hdpi or dimens-mdpi or ...
and can use dimens-small or dimens-large or ...
and can use both of them together. like dimens-larg-mdpi
but this is so hard to design.
i using dimens smallest screen width
this use density and i think you can handle all of phones or tablets by 4 or 5 dimens.
like this picture.
Typical numbers for screen width dp are:
320: a phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480: a tweener tablet like the Streak (480x800 mdpi).
600: a 7” tablet (600x1024).
720: a 10” tablet (720x1280, 800x1280, etc).
if you have a device don't support by one of these you can add
another smallest screen width for that.
you can read more details here , here , here and this help you know your phone pixels per inch.
example:
you have a phone 1080*1920 pixel and 5" size.
first formula help you calculate pixel per inch (dpi).
second formula help you calculate Pixel ratio.
and last formula help you calculate dp.
this phone have 392 dp in width and smallest width for that is 320.
if you like use dpi Pixel ratio can help you.
ldpi => Pixel ratio = 0.75
mdpi => Pixel ratio = 1.0
hdpi => Pixel ratio = 1.5
xhdpi => Pixel ratio = 2
xxhdpi => Pixel ratio = 3
xxxhdpi => Pixel ratio = 4
if you want to support all resolution (ldpi ,mdpi ,hdpi , xhdpi , xxhdpi , xxxhdpi ) then you can put your images those folders.
For text sizes its a good practice to use dimension folder. But if you do not want to use dimension folder then you can pick resolution of device programatically and change your text sizes
mipmap-hdpi, mipmap-mdpi,mipmap-xxhdpi, this folder are you that u need to use them for diffrent resolution
you can read : http://developer.android.com/guide/practices/screens_support.html

Large screens (2560x1600, 2048x1536, 1920x1200) width in dp

The info I have found:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
But its coming from 2011. Now is 2014 and there are 2048x1536, 2560x1600, 1920x1200 tablets and phones. Are they still 720dp width or it does exist also 800dp, 1024dp or any other? That remains unclear to me because all the discussions I have found are from 2011 year, when there were no such devices on market.
If it depends on manufacturer, can you please share info about Sony Xperia tablet Z and Samsung TabPro 10.1 width in dp?
It also depends on density, not only on resolution.
Here are the equivalent for dp to pixels according to density :
mdpi : 1 dp = 1 pixel
hdpi : 1 dp = 1.5 pixel
xhdpi : 1 dp = 2 pixels
xxhdpi : 1 dp = 2.5 pixels
So, yes, a device with a resolution of 2560x1600 in xhdpi is 1530 dp wide.

how to use the same image of 160ppi and 1280X800 ressolution device in 800X1280 and 214ppi device

I have a app which i developed for 10.1 inch tab which has resolution 1280x800 and having Density 160ppi,so when i am running the same app on a 7inch tab with has resolution of 800X1280 and having density 214ppi in that the UI of the app is looking kinda weird they are looking bigger as compare to 10inch tab. so what step should i follow to resolve this issue.Note: The Images that i am using in my App is initially designed 1280X800 and 160ppi density.
1280 x 800 160ppi is MDPI devices
800 x 1280 214PPi us TVDPI devices
//you need to supply different density Images like
MDPI and HDPI images
TVDPI devices will pick from HDPI image and auto scale them
//you can also supply different drawable for large and xlarge drawables.

Declaring Tablet Layouts for Android 3.2 - mild confusion

According to this guide's chapter px = dp * (dpi / 160) and to that layout specifications change from buckets(physical size in inches) to "dp" units so that:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800
hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
Since "dp" values depend on "px" and "dpi" values so that: dp = px / (dpi / 160) - isn't it possible that a phone device with high resolution will take a layout from w600dp folder?
For instance: Samsung galaxy s3 dp = 1280 / (303 / 160) = 670; Samsung galaxy s2 dp = 800 / (217 / 160) = 592. So, galaxy s3 is going to take "tablet-oriented" template, right. Is it okay, especially if a tablet version contains more elements and overall interface ergonomics gonna suffer from the tablet layout in case of s3 ? Why don't just stick to display buckets ?
You're probably going to recommend using "sw" key but I just want make sure that those "dp" units actually relate to sizes so that tablet-oriented template won't be shown on phone devices.
So, would you mind sharing your practical knowledge on applying the new approach ?
Thanks
A dp or dip is a (screen) Density Independant Pixel. The confusing part about that is that is mentions pixel. It is actually a unit similar to a centimeter or inch.
Each device defines a dpi bucket for it's screen, for example mdpi which is 160dpi. That means that you find 160 pixel across one inch on the screen. It's not 100% accurate since physical screens are usually not exactly 160 dpi (or whatever value that is defined for the bucket). But it's a value that comes close.
That means that 160dp on a perfect 160dpi screen are actually 160 pixel. On a device with a perfect xhdpi (=320dpi) screen those 160dp would be 320 pixel. (px = 160dp * (320dpi / 160))
To work with dp don't think in pixel. Think in inch, milimeter or what unit you prefer. The recommended 48dp rythm for UI elements for example explains that
On average, 48dp translate to a physical size of about 9mm (with some variability)
To approximate that: 50dp = one finger wide.
That hopefully explains why a typical 320dp phone screen is always smaller than a 720dp tablet screen although the smaller screen can have more pixel than the larger. The dpi / pixel thing is already factored into dp.
How to do different layout for different screensizes? (i.e. phone vs table)
Use the screen size buckets (small, ..., xlarge) for the layout. They represent physical small to large screens. You don't need sw600dp etc unless you need to adjust very special cases.
The different dpi buckets should only concern you for images. E.g. high resolution images for high resolution screens of any size in the drawable-hdpi folder.
The S3 does not have a density of 160.

Asset Creation - 9patch SplashScreen and ScreenDensity

So I get the whole Android pixel independency thing.
I'm creating a SplashScreen that is using a 9patch that will stretch its edges to account for all screensizes.
I also use a differenlty sized 9patch image in ldpi mpdi hdpi xhdpi for each splash screen as well.
That way the logo (the non stretched area of the 9patch) will be the correct size.
I know mdpi is 1.0 and hdpi x1.5 in relative size and xhdpi is x2, but when I'm creating that first mdpi image how do I know how many pixels wide/high it should be?
Hope that makes sense.
Really there's no one answer. Firstly though, I wouldn't start at mdpi and scale up -- It's best to start at the highest quality that you can. Vector, if it fits the design, or a high resolution image (even larger than the largest screen size you currently plan to support). Then, from there, just downsize for the device that you plan to test. For example, a typical HDPI resolution would be 480 x 800, so fit it appropriately there. An XHDPI resolution might be something like 1280 x 720. It's best to just leave a good amount of margin on the edges in case it's used on a device with a different aspect ratio, or something. But yeah, basically, design as large as you can, and then just export based on some average screen resolutions for the density bucket you're working on.
(...) when I'm creating that first mdpi image how do I know how many pixels
wide/high it should be?
Since mdpi is the baseline for all other density buckets, 1dp on an mdpi device will translate to exactly 1px. In other words, use an mdpi device to figure out the relative size on the screen and from there on apply the given scaling ratios to produce resources for the ldpi, hdpi and xhdpi buckets. Obviously you do not actually have to scale up that mdpi resource - all you need determine is the size for that screen density and then you can use whatever source file to produce images for all buckets.
The link xBroak has given, is actually the best source of information regarding your question. A quote from there to support above statements:
The density-independent pixel is equivalent to one physical pixel on a
160 dpi screen, which is the baseline density assumed by the system
for a "medium" density screen.
It may also come in handy to be aware of the simple d(i)p to px formula (also from that same link):
The conversion of dp units to screen pixels is simple: px = dp * (dpi
/ 160)
With this information, you can easily verify that 1dp on an mdpi device (with 160dpi screen) is equal to 1px. Just fill in 160dpi and you get px = dp * (160 / 160), which simplifies to px = dp * 1, and hence px = dp for 160dpi. QED. :)
These are your basic guidelines:
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
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
More info: http://developer.android.com/guide/practices/screens_support.html

Categories

Resources