平板电脑 - 获取可绘制屏幕分辨率,而不是总屏幕分辨率 [英] Tablet - Get Drawable Screen Resolution, Not Total Screen Resolution

查看:231
本文介绍了平板电脑 - 获取可绘制屏幕分辨率,而不是总屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着平板电脑和某些手机运行4.0上有屏幕控制。我正在开发一个全屏幕基于帆布游戏。我调整我的画布用一个矩阵来适应屏幕大小。

在有屏幕上的按钮,我的应用程序目前在绘制这些按钮的游戏控制的一部分的任何设备。

有没有办法来确定绘制的屏幕分辨率,IE分辨率减去任何屏幕上的按钮?

编辑:

这是我测试进行解析的方式

 显示显示=((活动)gameContext).getWindowManager()getDefaultDisplay()。Log.d(Display.getWidth():,Integer.toString(display.getWidth()));
Log.d(Display.getHeight():,Integer.toString(display.getHeight()));DisplayMetrics指标=新DisplayMetrics();
((活动)gameContext).getWindowManager()getDefaultDisplay()getMetrics(指标)。Log.d(Metrics.getWidth():,Integer.toString(metrics.widthPixels));
Log.d(Metrics.getHeight():,Integer.toString(metrics.heightPixels));


解决方案

使用了Android的 DisplayMetrics 类。它返回的数据是该地区提供的应用程序使用,不包括屏幕上的控制等等。

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.

这篇关于平板电脑 - 获取可绘制屏幕分辨率,而不是总屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆