it will help u dear

Display display = getWindowManager().getDefaultDisplay();
          int screenWidth = display.getWidth();
          int screenHeight = display.getHeight();
          float dips_120 = 120.0f;
        float scale = view.this.getResources().getDisplayMetrics().density;
        int pixels_120 = Math.round(dips_120 * scale);
        float dips_50 = 50.0f;
        int pixels_50 = Math.round(dips_50 * scale);




On Fri, Jun 22, 2012 at 8:41 PM, Raghav Sood <[email protected]> wrote:

> Hi,
>
> Does android have any method that returns the display width in dp?
> DisplayMetrics only seems to return the scale factor and exact pixels as
> far as I could tell from the docs, or did I miss something?
>
> If not, is there an exact formula I could use to calculate the display
> width in dp?
>
> Thanks
>
> --
> Raghav Sood
> Please do not email private questions to me as I do not have time to
> answer them. Instead, post them to public forums where others and I can
> answer and benefit from them.
> http://www.appaholics.in/ - Founder
> http://www.apress.com/9781430239451 - Author
> +91 81 303 77248
>
> --
> 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

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