You're right, setting dimensions through code only takes raw pixel
values.  You have to multiply the display density; something like this
should work:

final float density = getResources().getDisplayMetrics().density;
int pxSize = (int)((float)dipSize * density);

Or if you're writing your own views, you can use
TypedArray.getDimensionPixelSize() to read values as raw pixels.

j

On Thu, Aug 13, 2009 at 2:29 AM, Atif Gulzar<[email protected]> wrote:
> in xml file we can define measuring units along with the values.
>
> If I want to set some property through code it only takes "int" value. What
> is the default unit for this int?  px(pixels) or dp(density indipendent
> pixels) ?
>
>
> --
> Best Regards,
> Atif Gulzar
>
> I ◘◘◘◘ Unicode, ɹɐzlnƃ ɟıʇɐ
>
>
> >
>



-- 
Jeff Sharkey
[email protected]

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

Reply via email to