美文网首页
获取系统顶部状态栏(Status Bar)与底部导航栏(Navi

获取系统顶部状态栏(Status Bar)与底部导航栏(Navi

作者: AxeChen | 来源:发表于2016-10-26 18:56 被阅读170次

    Android一些设备都有上下两条bar,我们可以获取这些bar的信息。
    原文地址:http://www.cnblogs.com/rossoneri/p/4142962.html

    获取顶部status bar 高度

    private int getStatusBarHeight() {
        Resources resources = mActivity.getResources();
        int resourceId = resources.getIdentifier("status_bar_height", "dimen","android");
        int height = resources.getDimensionPixelSize(resourceId);
        Log.v("dbw", "Status height:" + height);
        return height;
    }
    

    获取底部 navigation bar 高度

    private int getNavigationBarHeight() {
        Resources resources = mActivity.getResources();
        int resourceId = resources.getIdentifier("navigation_bar_height","dimen", "android");
        int height = resources.getDimensionPixelSize(resourceId);
        Log.v("dbw", "Navi height:" + height);
        return height;
    }
    

    相关文章

      网友评论

          本文标题:获取系统顶部状态栏(Status Bar)与底部导航栏(Navi

          本文链接:https://www.haomeiwen.com/subject/azfjuttx.html