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

public static int getWindowWidth(Context context) {
    if (screenSize == null) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        screenSize = new Point();
        display.getSize(screenSize);
    }// ww  w .  j  a  v a  2 s  .  c  o  m
    if (screenSize != null)
        return screenSize.x;
    else
        return 0;
}

From source file:Main.java

public static int getWindowHeight(Context context) {
    if (screenSize == null) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        screenSize = new Point();
        display.getSize(screenSize);
    }//from   w  ww. j a va 2 s.  co  m
    if (screenSize != null)
        return screenSize.y;
    else
        return 0;
}

From source file:Main.java

public static int getDeviceWidth(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.x;
}

From source file:Main.java

public static int getDeviceHeight(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.y;
}

From source file:Main.java

public static int getDisplayWidth(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.x;
}

From source file:Main.java

public static Point getScreenSize(Context context) {
    WindowManager window = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = window.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;//from w ww. ja va  2 s. c o m
}

From source file:Main.java

public static Point getScreenDimensions(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;//from w  ww  .j av  a2 s. c  om
}

From source file:Main.java

public static Point getDisplaySize(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;/*from   w  w w. j  a va2 s. c  om*/
}

From source file:Main.java

public static float getScreenWidth(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.x;
}

From source file:Main.java

public static int getScreenHeight(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    return point.y;
}