开发者

Android, get screen size in api 3.2

开发者 https://www.devze.com 2023-04-04 11:32 出处:网络
In API 3.2 when you get the screen height, it seems that return value is the screen height minus the height menu bar.

In API 3.2 when you get the screen height, it seems that return value is the screen height minus the height menu bar. Here is the code:

((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics);
int height=met开发者_Python百科rics.heightPixels;

For API 3.2 emulator with 1280x800 screen size, the height return is 752

I tried to get the height with methods but always return 752


Ok I get the answer. In API 3.2 you need to get height and width in onSurfaceChanged method. If you need to get the real values you need to get height and width in portait and landscape mode and select the non reduced measure in both modes.

0

精彩评论

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