You can look into writing a utility method e.g. :

public class Util {
        private static float DIP_SCALE = -1;

        public static int dipsToPx(int dips, Context context) {
                if(DIP_SCALE == -1) DIP_SCALE = 
context.getResources().getDisplayMetrics().density; 
                return (int)(dips * DIP_SCALE + 0.5f); 
        }
}

and using that in your code...

On 15 Feb 2011, at 14:13, Pepijn Van Eeckhoudt wrote:

> On 15/02/2011 15:03, Deepak Kumar wrote:
>> 
>>                One of the solution can be multiplying these values with 
>> ratio (according to device).Is there any other way to do the same?
> In code, I define constants in 'dp' and then multiply with 
> DisplayMetrics#density at runtime to get the correct pixel value.
> 
> Pepijn
> 
> -- 
> 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

-- 
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