Android Screen Size Get getStatusHeight(Context context)

Here you can find the source of getStatusHeight(Context context)

Description

get Status Height

Declaration

public static int getStatusHeight(Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

public class Main {
    public static int getStatusHeight(Context context) {

        int statusHeight = -1;
        try {/*from  www.  j  a v a  2 s  .  c  om*/
            Class<?> clazz = Class.forName("com.android.internal.R$dimen");
            Object object = clazz.newInstance();
            int height = Integer.parseInt(clazz
                    .getField("status_bar_height").get(object).toString());
            statusHeight = context.getResources().getDimensionPixelSize(
                    height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return statusHeight;
    }
}

Related

  1. getDisplayMetrics(Context context)
  2. getDisplayWidth(Context context)
  3. getRawDisplayHeight(Context context)
  4. getScreenHeight(Context context)
  5. getScreenWidth(Context context)
  6. getScreenSize(@Nonnull Context context)
  7. getScreenHeight(Context context)
  8. getScreenWidth(Context context)
  9. getScreenSize(Activity act)