我想獲得運行我的應用程序的設備的實際屏幕高度。爲了實現這一點,我嘗試以下操作:獲取實際屏幕高度(android)
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int Height = metrics.heightPixels;
TextView HeightView = (TextView) findViewById(R.id.screenHeight);
HeightView.setText("Screen Height: " + Height);
int Width = metrics.widthPixels;
TextView WidthView = (TextView) findViewById(R.id.screenWidth);
WidthView.setText("Screen Width: " + Width);
,我運行使用仿真器具有1080個像素的屏幕寬度和1920個像素的屏幕高度的裝置。寬度顯示正確(1080像素),但高度根據應用程序只有1776像素。我需要什麼讓我的應用程序顯示正確的屏幕高度? metrics.heightPixels
是獲得屏幕高度的不好方法嗎?
非建議您的建議根據需要。 – lxknvlk