Android Utililty Methods StatusBar Size Get

List of utility methods to do StatusBar Size Get

Description

The list of methods to do StatusBar Size Get are organized into topic(s).

Method

intgetStatusBarHeight(Activity activity)
get Status Bar Height
Rect rect = new Rect();
Window win = activity.getWindow();
win.getDecorView().getWindowVisibleDisplayFrame(rect);
return rect.top;
intgetStatusBarHeight(Activity activity)
get Status Bar Height
try {
    Class<?> clazz = Class.forName("com.android.internal.R$dimen");
    Object object = clazz.newInstance();
    Field field = clazz.getField("status_bar_height");
    int dpHeight = Integer.parseInt(field.get(object).toString());
    return activity.getResources().getDimensionPixelSize(dpHeight);
} catch (Exception e1) {
    e1.printStackTrace();
...
intgetStatusBarHeight(Context context)
get Status Bar Height
int result = 0;
int resourceId = context.getResources().getIdentifier(
        "status_bar_height", "dimen", "android");
if (resourceId > 0) {
    result = context.getResources().getDimensionPixelSize(
            resourceId);
return result;
...
intgetStatusbarHeight(Activity activity)
get Statusbar Height
int statusbarHeight;
try {
    Rect frame = new Rect();
    activity.getWindow().getDecorView()
            .getWindowVisibleDisplayFrame(frame);
    statusbarHeight = frame.top;
} catch (Exception e) {
    statusbarHeight = getDensityDimen(activity,
...