简体   繁体   English

平板电脑-获取可绘制的屏幕分辨率,而不是总屏幕分辨率

[英]Tablet - Get Drawable Screen Resolution, Not Total Screen Resolution

With tablets and some phones running 4.0 there are on screen controls. 对于平板电脑和某些运行4.0的手机,可以在屏幕上进行控制。 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. 使用Android DisplayMetrics类。 The data it returns is the area available for the app to use, not including the on-screen controls and so forth. 它返回的数据是可供应用使用的区域,不包括屏幕上的控件等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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