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 getTitleBarHeight(Activity activity) { Rect rect = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int sbh = rect.top; int contentTop = activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop(); int titleBarTop = contentTop - sbh; return titleBarTop; } }