Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.graphics.Rect; import java.lang.reflect.Field; public class Main { public static int getStatusHeight(Activity activity) { int statusBarHeight = 0; try { Class<?> c = Class.forName("com.android.internal.R$dimen"); Object o = c.newInstance(); Field field = c.getField("status_bar_height"); int x = (Integer) field.get(o); statusBarHeight = activity.getResources().getDimensionPixelSize(x); } catch (Exception e) { e.printStackTrace(); Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); statusBarHeight = frame.top; } return statusBarHeight; } }