Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does density value calculate in android

Tags:

android

Can anybody explain me what formula android use to calculate screen density?

like image 531
teoREtik Avatar asked Feb 09 '11 08:02

teoREtik


People also ask

How is dp calculated in Android?

Dps and screen density A dp is equal to one physical pixel on a screen with a density of 160. To calculate dp: dp = (width in pixels *... A dp is equal to one physical pixel on a screen with a density of 160.

What is density in Android?

Density refers to how many pixels have been physically squeezed into a 1 inch x 1 inch area. In digital displays / screens like monitors, phones, and tablets, density measurement unit is PPI (pixels-per-inch).

Is dp the same as PX?

Definitions. px or dot is a pixel on the physical screen. dpi are pixels per inch on the physical screen and represent the density of the display. dip or dp are density-indenpendant pixels, i.e. they correspond to more or less pixels depending on the physical density.


1 Answers

Density can be calculated by the following formula:

Density = sqrt((wp * wp) + (hp * hp)) / di

Where:

wp is width resolution in pixels,

hp is height resolution in pixels, and

di is diagonal size in inches.

like image 146
Hari Kumar Avatar answered Oct 16 '22 21:10

Hari Kumar