发布于 5年前

Android 获取状态栏高度

/**
* 获取状态栏高度
*
* @param context
* @return
*/
public int getStatusBarHeight(Context context) {
    int statusBarHeight = 0;
    int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
    }
    return statusBarHeight;
}
©2020 edoou.com   京ICP备16001874号-3