get StatusBar Height from Context - Android User Interface

Android examples for User Interface:StatusBar

Description

get StatusBar Height from Context

Demo Code


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

public class Main {
    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);/*w  w  w .  j av a2  s.c o  m*/
        }
        return result;
    }
}

Related Tutorials