Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.graphics.Rect; import android.view.Window; public class Main { public static int getStatusBarHeight(Activity activity) { Rect rect = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rect); return rect.top; } }