Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
size in inches
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
bob  
View profile  
 More options Oct 11 2012, 11:36 am
From: bob <b...@coolfone.comze.com>
Date: Thu, 11 Oct 2012 08:36:19 -0700 (PDT)
Local: Thurs, Oct 11 2012 11:36 am
Subject: 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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piren  
View profile  
 More options Oct 11 2012, 12:06 pm
From: Piren <gpi...@gmail.com>
Date: Thu, 11 Oct 2012 09:06:03 -0700 (PDT)
Local: Thurs, Oct 11 2012 12:06 pm
Subject: Re: size in inches

Assuming you meant the device's screen sizes (you wrote "of a device", not
the screen size) then the sizes are correct for most of the time.

When the app is running on a device that has no physical buttons or running
on an ICS+ device while being targeted lower (thus causing the menu bar to
show) the screen size is reported sans that bar.

As an example, a galaxy nexus while being 720x1280  (4.65 inches diagonal)
is reported as 720x1184 (4.36 inches diagonal).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Latimerius  
View profile  
 More options Oct 15 2012, 11:11 am
From: Latimerius <l4t1m3r...@gmail.com>
Date: Mon, 15 Oct 2012 17:08:58 +0200
Local: Mon, Oct 15 2012 11:08 am
Subject: Re: [android-developers] size in inches

Yes, looks good, just keep in mind that some devices report incorrect
values in xdpi & ydpi.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »