In some cases, you will need to express dimensions in <code>dp</code> and then convert them to pixels. Imagine an application in which a scroll or fling gesture is recognized after the user's finger has moved by at least 16 pixels. On a baseline screen, a user's must move by <code>16 pixels / 160 dpi</code>, which equals 1/10th of an inch (or 2.5 mm) before the gesture is recognized. On a device with a high density display (240dpi), the user's must move by <code>16 pixels / 240 dpi</code>, which equals 1/15th of an inch (or 1.7 mm). The distance is much shorter and the application thus appears more sensitive to the user.
To fix this issue, the gesture threshold must be expressed in code in <code>dp</code> and then converted to actual pixels. For example: