Android Utililty Methods Screen Size Get

List of utility methods to do Screen Size Get

Description

The list of methods to do Screen Size Get are organized into topic(s).

Method

intgetDisplayHeight(Context context)
get Display Height
if (displayHeight <= 0) {
    WindowManager wm = (WindowManager) context
            .getApplicationContext().getSystemService(
                    Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    displayHeight = dm.heightPixels;
return displayHeight;
PointgetDisplaySize(Display display)
get Display Size
Point size = new Point();
display.getSize(size);
return size;
intgetDisplayWidth(Context context)
get Display Width
if (displayWidth <= 0) {
    WindowManager wm = (WindowManager) context
            .getApplicationContext().getSystemService(
                    Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    displayWidth = dm.widthPixels;
return displayWidth;
intgetScreenHeight(Context context)
get Screen Height
WindowManager manager = (WindowManager) context
        .getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics(dm);
return dm.heightPixels;
intgetScreenHeight(Context context)
get Screen Height
DisplayMetrics metric = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context
        .getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metric);
return metric.heightPixels;
intgetScreenHeight(Display display)
get Screen Height
Point size = getDisplaySize(display);
return size.y;
int[]getScreenPixel(Activity activity)
get Screen Pixel
DisplayMetrics displayMetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay()
        .getMetrics(displayMetrics);
return new int[] { displayMetrics.widthPixels,
        displayMetrics.heightPixels };
intgetScreenWidth(Context context)
get Screen Width
WindowManager manager = (WindowManager) context
        .getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics(dm);
return dm.widthPixels;
intgetScreenWidth(Context context)
get Screen Width
DisplayMetrics metric = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context
        .getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metric);
return metric.widthPixels;
intgetScreenWidth(Display display)
get Screen Width
Point size = getDisplaySize(display);
return size.x;