开发者

Wrong dimensions returned from Display and DisplayMetrics in Android 3.2?

开发者 https://www.devze.com 2023-03-24 23:07 出处:网络
I was using this code to get full screen size in my application Display display = getWindowManager().getDefaultDisplay();

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 DisplayM开发者_如何学JAVAetrics 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消