欢迎来到代码驿站!

Android代码

当前位置:首页 > 移动开发 > Android代码

Android NavigationBar问题处理的方法

时间:2021-04-05 10:10:30|栏目:Android代码|点击:

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

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

上一篇:Android开发中滑动分页功能实例详解

栏    目:Android代码

下一篇:Android实现九宫格拼图游戏

本文标题:Android NavigationBar问题处理的方法

本文地址:http://www.codeinn.net/misctech/94972.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有