0

I'm trying to define a line in Android which measure must be 10cm wide. I tried to put the width in mm and inches, but the results weren't satisfactory.

Also, I tried to follow this link: draw square 3x3 cm in Android

Desperately, i tried to measure 10cm in dip on the screen, but not is the same length in all screens

Is there any way to get it?

Thanks

Community
  • 1
  • 1
user2318814
  • 15
  • 1
  • 4

4 Answers4

0

I think: height of screen (cm) / height resolution(pixel) * 3 = 3 cm height in pixel for that screen and resolution. width of the screen (cm) / width resoluzion(pixel) * 3 = 3 cm width in pixel for that screen and resolution.

0

Not sure about this.

REFER LINK TO GET dpi

nbpixel(1 inch) = densityDpi

so convert 1 cm to inch who give approximativly 0.4 inch

nbpixel(1cm) = 0.4 * densityDpi

So for make a ligne of one cm you must draw 0.4*DPI pixel

Jebik
  • 778
  • 2
  • 8
  • 26
0

To draw a line of 1 cm, you must use multiple dpi (pixel density) to find the number of physical pixels. dpi/2.54

Mobile device displays also have something which is called devicePixelRatio. You might want to check that too. When building RealRuler (online ruler) I used to multiple mobile screen width/height with that ratio to get actual size. Not sure if it impacts actual size in cm in Android.

All this is very tricky.

-1

An inch or a mm are unit of linear measurement on a surface, which could be a screen or a piece of paper.I'm strange if the result is not satisfactory for you.See this answer for more details.

Community
  • 1
  • 1
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167