首页 > 系统 > Android > 正文

Android NavigationBar问题处理的方法

2019-12-12 01:51:48
字体:
来源:转载
供稿:网友

如图,现在全面屏手机下面的 按钮在屏幕上,如果做沉浸式的话,下面的菜单会沉入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;    }  }

由于工作原因,暂时做简单记录,有空会进行深入分析!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表