Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong dimensions returned from Display and DisplayMetrics in Android 3.2?

Tags:

android

I was using this code to get full screen size in my application

Display display = getWindowManager().getDefaultDisplay();
int w = display.getWidth();
int h = display.getHeight();

On my tablet, until osVersion = 3.1, this code returned a w=1280 and h=800.

Now, after an upgrade to Os 3.2, these values are 1280x752 (when in landscape)

So it seems that something is changed from 3.1 to 3.2 regarding this call: it now returns available space, not full screen size.

I've tried using DisplayMetrics and widthPixels/heigthPixels but they return same values. Also using the brand new display.getSize(Point p) return the same values

I've also tried changing minSdkVersion and targetSdk in my manifest file to different values without success.

How to get back full screen size in Android os 3.2 ?

My app should be compatible with android os >=1.6

like image 227
Fabio Avatar asked Aug 04 '11 06:08

Fabio


1 Answers

The difference is due to the soft-keys. 3.2 take them into account when you query for the available screen size but 3.1 doesn't.

You will notice that if you turn the tablet to landscape mode the numbers reported will change as well.

like image 63
ADB Avatar answered Oct 18 '22 17:10

ADB