android navigation bar高度,Android获取屏幕真实高度包含NavigationBar(底部虚拟按键)
釋放雙眼,帶上耳機,聽聽看~!
public int getScreentHeight() {
int heightPixels;
WindowManager w = this.getWindowManager();
Display d = w.getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
d.getMetrics(metrics);
// since SDK_INT = 1;
heightPixels = metrics.heightPixels;
// includes window decorations (statusbar bar/navigation bar)
if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17)
try {
heightPixels = (Integer) Display.class
.getMethod("getRawHeight").invoke(d);
} catch (Exception ignored) {
}
// includes window decorations (statusbar bar/navigation bar)
else if (Build.VERSION.SDK_INT >= 17)
try {
android.graphics.Point realSize = new android.graphics.Point();
Display.class.getMethod("getRealSize",
android.graphics.Point.class).invoke(d, realSize);
heightPixels = realSize.y;
} catch (Exception ignored) {
}
Log.e("realHightPixels-heightPixels", heightPixels + "width");
return heightPixels;
}
總結
以上是生活随笔為你收集整理的android navigation bar高度,Android获取屏幕真实高度包含NavigationBar(底部虚拟按键)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 黑盒测试用例设计方法
- 下一篇: 在laravel5.8中集成swoole