Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.graphics.Rect; public class Main { public static int getSystemUiStatusBarHeight(Activity activity) { final int statusBarResId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (statusBarResId > 0) { return activity.getResources().getDimensionPixelSize(statusBarResId); } else { final Rect rect = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); return rect.top; } } }