Pretty much all of the Java graphics/layout APIs in Android work with raw pixel values (measure, layout, draw) consistently. The design intention (as I understand it) is that complex units are best defined in XML resources (layout.xml, dimens.xml, etc.). When pulling resources into your Java code, the methods on Resources (such as getDimensionPixelSize() for dimensions) will do the work of converting the complex type into pixels for that devices.
If you have a handful of raw dimensions you want to define explicitly for use in Java code, put them in a dimens.xml. That will allow you the flexibility to provide a separate value for the same resource on different device configurations. This is why Google prefers this pattern over you trying to construct a complex unit from a Java constant (which can't be controlled per device configuration) using something like TypedValue.applyDimension().
BTW, the complex type identifiers do already exist as constants on
TypedValue:
Cheers,
--
Dave Smith, PE
@devunwired