Fabio
Fabio

Reputation: 51

Wrong dimensions returned from Display and DisplayMetrics in Android 3.2?

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

Upvotes: 5

Views: 1063

Answers (1)

ADB
ADB

Reputation: 2329

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.

Upvotes: 3

Related Questions