Pt Points

• dp. Density-independent pixels based on a 160-dpi (pixel density per inch) screen (dimensions adjust to screen density)

• sp: Scale-independent pixels (dimensions that allow for user sizing; helpful for use in fonts)

In Java, you need to access your Resources object instance to retrieve a dimension. You can do this by calling getResources on an activity object (see Listing 3-10).

Listing 3-10. Using Dimension Resources in Java Code float dimen = activity.getResources().getDimension(R.dimen.mysize_in_pixels);

0 0

Post a comment