Thursday, October 11, 2012

[android-developers] size in inches

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?

Or is there a better way?

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


Real Estate