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 Point getScreenSize(final Activity a) {
    Display display = a.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;/*from  www .  ja v a 2s  .  c  om*/
}

From source file:Main.java

public static Point getAppUsableScreenSize(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;/* w  ww . j  a  v a2s . c  o m*/

}

From source file:Main.java

public static int getScreenWidth(Context context) {
    if (screenWidth == 0) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        screenWidth = size.x;//from  w  w  w .ja  va2s . c om
    }
    return screenWidth;
}

From source file:Main.java

/**
 * Gets screen width.//from   w  w w .j av  a2 s .co m
 *
 * @param context the context
 * @return the screen width in pixels
 */
public static int getScreenWidth(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.x;
}

From source file:Main.java

/**
 * Returns the screen/display size/*from   w w w.  java  2 s.c o  m*/
 */
public static Point getDisplaySize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;
}

From source file:Main.java

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);
        screenHeight = size.y;//from  ww  w  .  ja  va 2 s.  co  m
    }

    return screenHeight;
}

From source file:Main.java

public static int getScreenWidth(Context c) {
    if (screenWidth == 0) {
        WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        screenWidth = size.x;// ww w  . ja v a  2  s. co  m
    }

    return screenWidth;
}

From source file:Main.java

public static boolean isVertical(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;

    if (width > height) {
        return false;
    } else {//from   w  w  w.  j ava  2s  . c o  m
        return true;
    }
}

From source file:Main.java

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

From source file:Main.java

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