获取有关冰淇淋三明治的实际屏幕分辨率明治、冰淇淋、实际、屏幕分辨率

2023-09-06 02:00:39 作者:我的爱太假

与冰淇淋三明治设备可以使用屏幕上的软按键,这意味着一些屏幕房地产的采取的是这些密钥。我需要真正的屏幕分辨率,而不是决议减去软键所占用的空间。

我已经试过以下,但既不作品:

 显示显示= getWindowManager()getDefaultDisplay()。
INT宽度= display.getWidth();
INT高= display.getHeight();
Log.d(SCREEN RES,宽:+宽+:+高的高度。);

DisplayMetrics指标=新DisplayMetrics();
。getWindowManager()getDefaultDisplay()getMetrics(度量)。
身高= metrics.heightPixels;
宽度= metrics.widthPixels;
Log.d(SCREEN RES,宽:+宽+:+高的高度。);
 

下面是输出:

  12-19 20:18:42.012:D /屏幕RES(20752):宽:1196高:720
12-19 20:18:42.012:D /屏幕RES(20752):宽:1196高:720
 

真正的屏幕分辨率为1280×720像素,而不是1196×720像素。

任何想法?

冰淇淋三明治

修改

我用下面的code,使应用程序全屏:

  getWindow()getDecorView()setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
 

解决方案

该API返回像素的应用程序可以使用的数量,所以这是正确的结果。

Devices with Ice Cream Sandwich can use on-screen soft keys, and this means that some of the screen estate is taken by these keys. I need to get the real screen resolution, and not the resolution minus the space taken up by the soft keys.

I've tried the following, but neither works:

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();
Log.d("SCREEN RES", "Width: " + width + ". Height: " + height);

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
height = metrics.heightPixels;
width = metrics.widthPixels;
Log.d("SCREEN RES", "Width: " + width + ". Height: " + height);

Here's the output:

12-19 20:18:42.012: D/SCREEN RES(20752): Width: 1196. Height: 720
12-19 20:18:42.012: D/SCREEN RES(20752): Width: 1196. Height: 720

The real screen resolution is 1280 x 720 pixels, not 1196 x 720 pixels.

Any ideas?

Edit

I'm using the following code to make the app full screen:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

解决方案

The API returns the number of pixels an app can use, so this is the correct result.

 
精彩推荐
图片推荐