android获取导航栏Navigation高度

 

/*
     *   获取底部栏的高度
     */
    public int getNavigationHeight(Context context) {
        if (context == null) {
            return 0;
        }
        if(checkHasNavigationBar(context)){ //这个函数请查看上一片文章
            return 0;
        }
        Resources resources = context.getResources();
        int resourceId = resources.getIdentifier("navigation_bar_height",
                "dimen", "android");
        int height = 0;
        if (resourceId > 0) {
            //获取NavigationBar的高度
            height = resources.getDimensionPixelSize(resourceId);
        }
        return height;
    }

 

posted @ 2020-11-18 18:04  野生野鸡码农  阅读(642)  评论(0编辑  收藏  举报