I'm just reading about dimension resources (Pro Android 4), and it seems 
curious how dimension resources are referenced in Java code (at least as 
specified in this book).

The resource value consists of the value and the dimension, like "5px" or 
"5dp" or "5sp".

You could reference this in a layout resource, like to set the "textSize" 
of a TextView.  My assumption is that the unit specified in the dimension 
would be used in that calculation, which would result in slightly different 
sizes for the previous examples. That is only an assumption. It seems 
reasonable.  What would be the point of specifying the unit if it isn't 
used anywhere?

In Java code, however, it appears that you reference a dimension resource 
like this:

float dimen = 
> activity.getResources().getDimension(R.dimen.mysize_in_pixels);
>

That looks to me like it's only returning the dimensionless value ("5", for 
instance). 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to