问题
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