Can some one explain me the relation between
LED Pixel density,
LED Pixel height and width , and
Resolution
while creating an emulator
in detailed way..
and again while launching
Default: SkinSize, Density;
Scale density to realsize ?
Pixel density : Pixels per inch (PPI) or pixel density is a measurement of the resolution of devices in various contexts: typically computer displays, image scanners, and digital camera image sensors.
Resolution: or the total number of pixels in a display, is a very important factor that affects the performance of the sign. More resolution means more LED diodes and more circuits, which usually means better picture quality.
Pixel have fixed size height and width, it's just a dot, the no of dots in an inch creates resolution.
Related
I searched a lot about dp, px, inch, pt etc.
From what I understood about 'dp':
Specifying 'dp' is simply a way to make Android draw the views with same size for devices with different screen densities. Eg, for a medium density device, each 'dp' will occupy a pixel. For a high density device - which has smaller pixels to fit more pixels per inch, 'dp' will occupy more than a pixel. For a low density device - which has larger pixels to fit less pixels per inch, 'dp' will occupy less than a pixel.
But what I also read is that space occupied by a 'dp' varies according to screen sizes, i.e for a small screen a 'dp' will occupy less space, while for a larger screen a 'dp' will occupy larger space.
How exactly does this happen? From what I understood about 'dp', it should occupy the same amount of space in devices with differing screen sizes. Eg, a large screen of 240 dpi will have a 'dp' occupy 1.5 pixels, and so will be the case for a small screen of 240 dpi. Then how is it that a 'dp' will occupy different amount of space for different screen sizes?
What am I missing in my understanding of 'dp'? Please help.
Android defines a baseline dpi of 160 which is used as the reference to compute sizes for all screen densities:
pixel_size * (device_dpi / baseline_dpi) = result in "dp" units
>> or the other way around
dp_size / (device_dpi / baseline_dpi) = result in "pixel" units
Therefore, 1 pixel in a 240dpi device is equivalent to 1.5dp units:
1 * (240 / 160) = 1.5
and the other way around, 1.5dp units in a 240dpi device is equivalent to 1 pixel
1.5 / (240 / 160) = 1
The important fact to know is that 160 is the baseline used as the reference for all DPIs.
So, as dp units increase/decrease, the required pixels area to draw something translates into keeping the same size scale regardless of the device screen.
More information in the official documentation.
To be more clear:
The display size is not related to "dp units". The display size is just how big the display canvas is. The screen DPI defines how many dots fit in 1 square inch. And a "dp unit" is an abstract unit that, depending on the device's DPI, is scaled (up or down) to give "uniform dimensions" on any screen size, by using 160 as the baseline reference.
on the Android operating system a device-independent pixel is equivalent to one physical pixel on a 160 dpi screen. By this definition, you can understanddp has no relation with screen sizes as the scale is already fixed as 160 dpi.
.
I need help understanding the subject. I tried many times to develop something in Android and every single time i get stuck at this.
Currently i have two virtual devices:
480x800 mdpi
480x800 hdpi
Now in my view with a canvas i want to draw a rectangle with
canvas.drawRect(0, 0, 100, 100);
So the results are:
mdpi rect of 100px (size measured with gimp).
hdpi rect of 88px (size measured with gimp).
So my question is, if i want to make this rectangle move and control collisions with screen limits how i can get the scale factor that has been applied from density, how i get that the final size of my rect is 88px instead of 100px?
EXTENSION: From this point is it possible that in both devices the rect size will be 100px? What is the formula to achieve this?
Actually, the rectangle is exactly 100px wide on both devices. What you actually measured was the physical width of the rectangle.
Confused? Let me explain:
The rectangle gets drawn as exactly 100px wide on both devices. They have the same screen resolution, but one has a lower density, measured in dpi (= dots per inch) or sometimes ppi (= pixels per inch). (In Android, as you might already know mdpi means medium dpi (~160dpi) and hdpi means high dpi (~240dpi))
Now, dpi is nothing else than the physical size of one pixel, instead of saying there are 160 pixels/inch you could also say one pixel is 0.something inches big.
That means the physical size of the rect you draw is the width of the rectsize of one pixel. Also, the width of the screen is the resolution in pxsize of one pixel. (Actually, the screen of the mdpi device should be displayed smaller than the hpdi device's one)
What happens is that the emulator takes your monitors dpi into account and scales the device accordingly. For your mdpi device it just works out that one device pixel is translated to one monitor pixel, for the hdpi device one device pixel is equal to 0.88 monitor pixels.
In other words, the if these were real phones, the mdpi would have a bigger screen allthough both have the same resolution. The rect would be 100px wide on both but since a pixel on the mdpi phone is bigger the rect would be physically bigger. The pixels on your monitor thus actually are the physical size of the rect.
If you still have no idea what i'm talking about, read this article about supporting different screens in android.
I'm asking this question after much reading. I've always heard that dpi is for printers, but when it comes to screen now, they are also talking about dpi. Are they referring to ppi?
Now, what is really resolution, for me its the the number of pixels each dimension can display, e.g. 800x600 means 800 pixesl on width and 600 pixels on the height, but at some places I'm seeing that they are referring to resolution as dpi.
I'm trying to understand this concept well because its very important in Android, like in this article,
For example, say an icon is intended to be 0.5x0.5 in when rendered on a screen. Next, the image must be created at the largest density supported, or as a scalable vector graphic. Best practice is to support the maximum density, which currently is xxhdpi at 480 dpi. At 480 dpi, a 0.5x0.5 in image converts to 240x240 px.
So it is referring dpi as ppi actually if I understand?
So far what I've understood is that different pixels may render different number of pixels. This is why we don't use pixels as measurement unit. Instead we use dp, where a dp is one pixel on 160 dpi device (again the confusion about dpi & ppi)
Can someone clear this big confusion or direct me to an article that may clear it
Mate, Resolution being 800 X 600 implies that the screen has 480,000 pixel points that will be used to render the screen(This is often confused with the dimensions of the display). DPI or PPI means dots/points per inch, this is the measure of the density of the screen.
So just given the Resolution, one can not determine the actual length of the display unless the density parameter is also available. So a 800 X 600 resolution has 480,000 Pixel points & a let this device has a density of 480 dpi.
So the Width of the screen
= No of pixel points along its width/Density
= 800/480
= 1.67 inches
Similarly,
Height = 600/480
=1.25 inches
and if 800X600 resolution device has density of 160 dpi, its dimensions will vary drastically. Following calculations calculate Height/Width of 800X600 on 160 dpi. Compare these two values with above 480 dpi calculations.
the Width of the screen
= No of pixel points along its width/Density
= 800/160
= 5.0 inches
Similarly,
Height = 600/160
=3.75 inches
This is the very reason that scaling images to best fit the screen is such a complex issue on frafmented android environment.However, I love android!
Hope this helps!
and any one who has some thing to add/delete.modify to this answer is most welcome.
dpi (dots per inch) == ppi (pixels per inch)
You are also talking about the DisplayMetrics.density, which gives you the multiplier for the dp unit of measurement.
There's also DisplayMetrics.scaledDensity which also takes into account text size user chose.
To put it plainly, dp unit is intended to give you some security about size of your objects on screen. 160dp should represent one inch on any screen. In order to achieve that, you have to multiply your dimension by DisplayMetrics.density or DisplayMetrics.scaledDensity.
That is, if you're doing that in code. For Layouts, you can just enter a View's dimensions in dp and have Android framework take care of that for you.
I have a few questions:
What is the screen size?
What is the screen density?
What is a difference between screen size and screen density?
How I can support different densities and different screen sizes in Android?
I have already read the official documentation, but I was unable to understand the difference between screen size and screen density.
screen size is about how many pixels you can show on screen.
Density is based on your device real size, if it's small and has a higher resolution, than the density is high cause you show more pixels in less physical space.
1.screen size concerns an absolute number of pixels. (check out wikipedia Image Resolution)
2.Density (aka Pixels per inch - PPI) concerns a relative number of pixels per inch. (check out the wikipedia Pixel Density)
To put it simple:
Screen size is the physical size of the screen (whether in inch or cm)
Screen density is the ratio of how many pixels / area of screen size (that's why the unit is dpi, or dots per inch)
Simply put, screen size refers to the size of the screen.This varies from device to device.screen density refers to the amount of pixels in a screen.Both are not independent though as screen size affects screen density.
There are different terms and can't be used interchangeably
density = how many pixels appear within a constant area of the display, dots per inch = dpi or ppi(pixels per inch )
size = amount of physical space available for displaying an interface, screen's diagonal, inch
resolution = number of pixels available in the display, scale-independent pixel = sp
As the titles,the following is some arguments of the psd of my phone:
The width pixels:
The height pixels:
The width of document is:13.333 inch
The height of document is :7.5 inch
so the dpi will be 96,and we will know the phone is just a ldpi phone as the http://developer.android.com/guide/practices/screens_support.html
can anyone tell me whether it is right or not.
If your graphics are designed to display at 96 pixels/inch, then they are not a good match for Android. The minimum density devices are nominally 120 pixels/inch (called LDPI). If you put your graphics in res/drawable-ldpi, they will appear about 96/120 (or about 3/4) their original size (in inches).
If the images are displayed on a higher density device, Android will automatically scale the images up, so they will keep this size ratio regardless of actual device pixel density.
The only way to fix this is to rescale your images before adding them to yuor project. You will get the best quality if you rescale to each of the nominal pixel densities (120, 160, 240, and 320; you could also throw in 213 for tvdpi screens).