狀態欄與底部導航欄


/*獲取狀態欄的高度,有時候出現popuwindow超出屏幕時,減去它,默認24dp*/

//獲取頂部狀態欄的高度
 private int getStatusBarHeight() {
    Resources resources = MainActivity.this.getResources();
    int resourceId = resources.getIdentifier("status_bar_height", "dimen","android");
    int height = resources.getDimensionPixelSize(resourceId);
    Log.v("dbw", "Status height:" + height);
    return height;
}

 //獲取底部 navigationbar的高度
private int getNavigationBarHeight() {
    Resources resources = MainActivity.this.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height","dimen", "android");
    int height = resources.getDimensionPixelSize(resourceId);
    Log.v("dbw", "Navi height:" + height);
    return height;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章