使用各种系统参数来判断,很多机型的判断结果会有问题。
可使用另外一个办法来判断:获取当前页面根节点距离屏幕顶部的距离,和当前屏幕可用高度进行对比
获取当前页面根节点距离屏幕顶部的距离
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);