Dimension Resources

Pixels, inches, and points are all examples of dimensions that can play a part in XML layouts or Java code. You can use these dimension resources to style and localize Android UIs without changing the source code.

Listing 3-9 shows how you can use dimension resources in XML.

Listing 3-9. XML Syntax for Defining Dimension Resources


<dimen name="mysize_in_pixels">1px</dimen> <dimen name="mysize_in_dp">5dp</dimen> <dimen name="medium_size">100sp</dimen> </resources>

You could specify the dimensions in any of the following units:

0 0

Post a comment