Tuesday, July 5, 2011

Android What Does DIP Stand For?

This article introduces the concept of DIPs for Android.

What Does DIP Stand For?

DIP stands for Density Independent Pixels. Density Independent Pixels are also abbreviated as DP.

One Density Independent Pixel is defined as one pixel on a 160 DPI (dots per inch) screen.

Why Use DIPS?

Perhaps you have seen in an example project or tutorial DIPs mentioned in Android projects. Since different phones can have different screen densities, you can not simply use pixels as a unit of measurement.

For example, if you wanted to draw an image that was 1 inch wide, and you specified the width as 160 pixels, on a 160 dpi screen the image would be 1 inch wide, but on a 320 dpi screen it would be half and inch.

However, if you specified the width of the image to be 160dip or dp (both abbreviations are acceptable in the Android SDK) then the Android System will automatically scale the image appropriately and it will look the same on both screens.

Scale-Independent Pixels (SP)

And to make things just a little more confusing, there are also Scale-Independent Pixels.

Text sizes should be defined in SP units.

These operate in a similar fashion to DIPs, but take into account a user setting that scales text sizes.

Final Thoughts

It can be very difficult to design an Android App that will work on devices of all sizes but Android provides a lot of different tools to help with this.

Official Android Documentation on Supporting Multiple Screens

1 comment:

  1. Will u plz tell how to add more than one view to an activity