0

Is there an API in Android that returns the full screen height of the device? I'm interested in the full height as specified in the device spec, not the height of the viewable screen as returned by

android.view.Display.getHeight();
RobinHood
  • 10,897
  • 4
  • 48
  • 97
John W
  • 610
  • 8
  • 20

3 Answers3

1

I spent some time looking for this and didn't find anything like what you're asking for. Part of the problem is that the bar that takes up the pixels they're not including can potentially be of different sizes.

What I ended up doing is measuring the width of the device (which is the full width) and the not-quite-full-height to match against the standard resolutions with an approximate. It's not great. If you really need it exact, you can force an orientation change to match both dimensions exactly. That's pretty gross, though.

The real answer is that you're not supposed to care about the exact dimensions of the hardware and design using the OS-provided size buckets.

Argyle
  • 3,324
  • 25
  • 44
1

Does this not work for you?

        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        displayHeight = dm.heightPixels;

For me, displayHeight returns 960 pixels on my HTC Sensation

azgolfer
  • 15,087
  • 4
  • 49
  • 46
  • On my Gallaxy Nexus, it gives 1184 (Spec Height: 1280) - same as the return value from Disaply.getHeight(). – John W Jun 18 '12 at 22:05
  • Interesting. The virtual navigation bar in the bottom of GNexus caused the missing pixel height. Google should have provided a sets of API to get the real device resolutions. See this post for 'undocumented' solution: http://stackoverflow.com/questions/10991194/android-displaymetrics-returns-incorrect-screen-size-in-pixels-on-ics – azgolfer Jun 18 '12 at 23:01
0

Try heightPixels on a DisplayMetrics object.

RobinHood
  • 10,897
  • 4
  • 48
  • 97
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491