Example usage for android.view Display getSize

List of usage examples for android.view Display getSize

Introduction

In this page you can find the example usage for android.view Display getSize.

Prototype

public void getSize(Point outSize) 

Source Link

Document

Gets the size of the display, in pixels.

Usage

From source file:Main.java

private static void getScreenMetric(Context cxt) {
    WindowManager wm = (WindowManager) cxt.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    mScreenWidth = size.x;/*ww  w  . j  a v a 2  s  .  c o m*/
    mScreenHeight = size.y;
}

From source file:Main.java

public static float[] get_show(Context context) {
    float[] greenshow = new float[2];
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    greenshow[0] = size.x;/*from   w w w  .  j  a va  2  s  . co m*/
    greenshow[1] = size.y;
    return greenshow;
}

From source file:Main.java

public static int getHeightWindowWithContext(Context mContext) {
    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.y;
}

From source file:Main.java

public static int getHeightScreen(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.y;
}

From source file:Main.java

public static String getScreenWxH(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    return width + "x" + height;
}

From source file:Main.java

public static Point getDisplaySize(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    return point;
}

From source file:Main.java

/**
 * Getter for the screen width in pixels.
 *
 * @param context a reference to the context.
 * @return the screen width in pixels./*  w ww  . j a  v  a 2  s  .c o  m*/
 */
public static int getScreenWidth(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.x;
}

From source file:Main.java

public static int calculateImageSize(WindowManager window, int divider) {
    Display display = window.getDefaultDisplay();
    Point resolution = new Point();
    display.getSize(resolution);
    int width = resolution.x / divider;
    int height = resolution.y / divider;

    return Math.min(width, height);
}

From source file:Main.java

public static int getScreenHeight(Context c) {
    WindowManager windowManager = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();

    Point point = new Point();
    display.getSize(point);

    return point.y;
}

From source file:Main.java

public static int getScreenWidth(@NonNull Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    return point.x;
}