Android Screen Size Get getDisplayHeight(Context context)

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

Description

get Display Height

Declaration

public static synchronized int getDisplayHeight(Context context) 

Method Source Code

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

import android.os.Build;

import android.view.Display;
import android.view.WindowManager;

public class Main {
    public static final int GENERAL = 0;
    public static final int PLAYBOOK = 1;
    public static final int LEPAD = 2;
    public static final int GT_P7500 = 3;

    public static synchronized int getDisplayHeight(Context context) {
        Display display = ((WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay();//from w w  w.  j  a v  a  2s  . c  o m
        return display.getHeight() - getStatusBarHeight(display.getWidth());
    }

    private static int getStatusBarHeight(int width) {
        // 240x320 - 20px 320x480 - 25px 480x800+ - 38px
        int model = getModel();
        if (model == PLAYBOOK) {
            return 0;
        } else if (model == LEPAD) {
            return 50;
        } else if (model == GT_P7500) {
            return 48;
        } else if (width <= 240) {
            return 20;
        } else if (width <= 320) {
            return 25;
        } else {
            return 38;
        }
    }

    public static int getModel() {
        String model = Build.DEVICE.toLowerCase();
        if (model.indexOf("playbook") >= 0) {
            return PLAYBOOK;
        } else if (model.indexOf("lepad") >= 0) {
            return LEPAD;
        } else if (model.indexOf("gt-p7500") >= 0) {
            return GT_P7500;
        } else {
            return GENERAL;
        }
    }
}

Related

  1. getScreenSize(Activity ctx)
  2. getScreenSize(Context context)
  3. getScreenSize(Context ctx)
  4. getMinTouchHeight(Context context)
  5. getMinTouchWidth(Context context)
  6. getDisplayMetrics(Context context)
  7. getDisplayWidth(Context context)
  8. getRawDisplayHeight(Context context)
  9. getScreenHeight(Context context)