使用各種系統參數來判斷,很多機型的判斷結果會有問題。
可使用另外一個辦法來判斷:獲取當前頁面根節點距離屏幕頂部的距離,和當前屏幕可用高度進行對比
獲取當前頁面根節點距離屏幕頂部的距離
View rootView=getView(R.id.root); Rect rect = new Rect(); rootView.getGlobalVisibleRect(rect); int rootViewY=rect.bottom;
當前屏幕可用高度
int screenHeightPx=context.getResources().getDisplayMetrics().heightPixels;
判斷底部導航是否可見
boolean bottomNavVisible=(rootViewY==screenHeight);