Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;
import android.content.Context;

import android.view.Window;

public class Main {

    public static int getTitleBarHeight(Context context) {
        int height = ((Activity) context).getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
        if (height == 0) {
            return 0;
        }
        return height - getStatusBarHeight(context);
    }

    public static int getStatusBarHeight(Context context) {
        int result = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }
}