Tablet - Get Drawable Screen Resolution, Not Total Screen Resolution

本小妞迷上赌 提交于 2019-12-11 05:23:21

问题


With tablets and some phones running 4.0 there are on screen controls. I am developing a full screen canvas-based game. I adjust my canvas to fit the screen size with a matrix.

On any device that has on screen buttons my app currently draws part of the games' controls under those buttons.

Is there a way to determine the drawable screen resolution, IE the resolution minus any onscreen buttons?

EDIT:

This is the way I'm testing for resolution

Display display = ((Activity) gameContext).getWindowManager().getDefaultDisplay(); 

Log.d("Display.getWidth(): ", Integer.toString(display.getWidth()));
Log.d("Display.getHeight(): ", Integer.toString(display.getHeight()));

DisplayMetrics metrics = new DisplayMetrics();
((Activity) gameContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);

Log.d("Metrics.getWidth(): ", Integer.toString(metrics.widthPixels));
Log.d("Metrics.getHeight(): ", Integer.toString(metrics.heightPixels));

回答1:


Use the Android DisplayMetrics class. The data it returns is the area available for the app to use, not including the on-screen controls and so forth.



来源:https://stackoverflow.com/questions/11620564/tablet-get-drawable-screen-resolution-not-total-screen-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!