0

72 pts is always equal to 1 inch, yet 160 dip is not always equal to 1 inch.

As such, why do people recommend us to use dips instead of pts?

Isn't it better to base our dimensions on pts which is predictable, instead of dips which is unpredictable?

Community
  • 1
  • 1
Sophie
  • 47
  • 7

3 Answers3

6

The reason why you should use dip (Density Indepentdent Pixel) is that this way your application will support multiple screen sizes. This means that if you set a value to 100dip, it would be translated into 75px on a low density screen (ldpi), 100px on a medium density screen (mdpi), 150px on a high density screen (hdpi) and 200px on a extra high density screen (xhdpi) but the layout will look the same on each screen (but scaled to the screen density).

The only reason to use pt is if you actually need the exact size and don't care about the screen density (I can't see when that would be the case).


You should read through this article to better understand why dp/dip is the way to go:

Supporting Multiple Screens

Also this similar question has a good explenation of the difference between the different units:

Difference of px, dp, dip and sp in android

Community
  • 1
  • 1
kaspermoerch
  • 16,127
  • 4
  • 44
  • 67
  • But 45 pts is not an exact size.. it might be translated into 50px on a small screen, 100px on a normal screen, and 150 px on a large screen, just like 100 dip isn't it? – Sophie Oct 21 '11 at 11:53
  • Check out the above links. They will explain more in depth. – kaspermoerch Oct 21 '11 at 11:59
4

Always use dip (Device Independent Pixel), this will respect the width and height of the device you're running on. So by using dip, the layout will be the same for all devices.

Carnal
  • 21,744
  • 6
  • 60
  • 75
1

if you want your app to work in just a single device or a single resolution, you can use pts. if you would like your app to work on multiple resolutions (which i think you would) you are better going with dip or dp. Try your app on different resolutions using the emulator and you would see what the issues are. The app will look different in different resolutions.

rfsk2010
  • 8,571
  • 4
  • 32
  • 46
  • Hence, just always use dip because then you are future proofed even if you think you only want the app to one on a single device at the moment. – Intrications Oct 24 '11 at 13:43