get Screen Height - Android android.view

Android examples for android.view:WindowManager

Description

get Screen Height

Demo Code

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.view.Display;
import android.view.WindowManager;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main{

    public static int getScreenHeight(Context c) {
        if (screenHeight == 0) {
            WindowManager wm = (WindowManager) c
                    .getSystemService(Context.WINDOW_SERVICE);
            Display display = wm.getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);//from   ww  w . j  a  va2 s  . c  om
            screenHeight = size.y;
        }

        return screenHeight;
    }

}

Related Tutorials