如圖,現在全面屏手機下面的 按鈕在屏幕上,如果做沉浸式的話,下面的菜單會沉入NavigationBar下方,造成重疊。

樣品機為華為.png
下面是解決辦法:
getWindow().getDecorView().findViewById(android.R.id.content).setPadding(0, 0, 0, getNavigationBarHeight());public int getNavigationBarHeight() { boolean hasMenuKey = ViewConfiguration.get(this).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (!hasMenuKey && !hasBackKey) { Resources resources = getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); //獲取NavigationBar的高度 int height = resources.getDimensionPixelSize(resourceId); return height; } else { return 0; } }由于工作原因,暫時做簡單記錄,有空會進行深入分析!
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。
新聞熱點
疑難解答