Java tutorial
//package com.java2s; import android.app.Activity; import android.graphics.Rect; import android.view.Window; public class Main { private static int statusBarHeight = -1; public static int getStatusBarHeight(Activity activity) { if (statusBarHeight > 0) { return statusBarHeight; } Rect rectgle = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectgle); statusBarHeight = rectgle.top; return statusBarHeight; } }