Re: [android-developers] size in inches
On Thu, Oct 11, 2012 at 5:36 PM, bob <bob@coolfone.comze.com> wrote:
> I'm trying to make a routine that gets the width and height of a device in
> inches:
>
> Here's what I came up with:
>
> public void get_display_size() {
>
> DisplayMetrics metrics = new DisplayMetrics();
> getWindowManager().getDefaultDisplay().getMetrics(metrics);
> float width_in = metrics.widthPixels / metrics.xdpi;
> float height_in = metrics.heightPixels / metrics.ydpi;
>
> }
>
> Does this look good?
Yes, looks good, just keep in mind that some devices report incorrect
values in xdpi & ydpi.
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home