Example usage for android.view Display getWidth

List of usage examples for android.view Display getWidth

Introduction

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

Prototype

@Deprecated
public int getWidth() 

Source Link

Usage

From source file:Main.java

/**
 * Returns the screen/display size/*from w  ww.  ja va2s.c o  m*/
 *
 * @param context
 * @return
 */
@SuppressWarnings("deprecation")
public static Point getDisplaySize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    return new Point(width, height);
}

From source file:Main.java

private static int getDisplayWidth(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    return display.getWidth();
}

From source file:Main.java

public static int[] getScreenSize(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();

    return new int[] { display.getWidth(), display.getHeight() };
}

From source file:Main.java

public static int getScreenWidth(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    return display.getWidth(); // deprecated
}

From source file:Main.java

public static int getScreenWidth(Activity a) {
    Display display = a.getWindowManager().getDefaultDisplay();
    int width = display.getWidth(); // deprecated

    return width;
}

From source file:Main.java

public static int[] getScreenDimension(Display display) {
    int[] dimension = new int[2];
    dimension[0] = display.getWidth();
    dimension[1] = display.getHeight();//ww w  .j a va2  s  . c  om

    return dimension;
}

From source file:Main.java

public static int setDynamicWidth(Activity activity) {
    Display display = (activity).getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    return width;
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point wh = new Point(display.getWidth(), display.getHeight());
    if (wh.x == 0 || wh.y == 0) {
        Log.e("AndroidUtils", "Screen resolution " + wh + " for " + context);
    }/*www  .j av a 2 s .  c om*/
    return wh;
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static int getScreenWidth(Activity activity) {
    int Measuredwidth = 0;
    Point size = new Point();
    WindowManager wm = activity.getWindowManager();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        wm.getDefaultDisplay().getSize(size);
        Measuredwidth = size.x;/*from w  ww.j a  va 2 s  .  co  m*/
    } else {
        Display d = wm.getDefaultDisplay();
        Measuredwidth = d.getWidth();
    }

    return Measuredwidth;
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static int getScreenHeight(Activity activity) {
    int Measuredheight = 0;
    Point size = new Point();
    WindowManager wm = activity.getWindowManager();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        wm.getDefaultDisplay().getSize(size);
        Measuredheight = size.y;//  ww  w  .j a va  2 s  .c o m
    } else {
        Display d = wm.getDefaultDisplay();
        Measuredheight = d.getWidth();
    }

    return Measuredheight;
}