简体   繁体   中英

Tablet - Get Drawable Screen Resolution, Not Total Screen Resolution

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));

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM