Example usage for android.graphics Point Point

List of usage examples for android.graphics Point Point

Introduction

In this page you can find the example usage for android.graphics Point Point.

Prototype

public Point() 

Source Link

Usage

From source file:Main.java

public static Point getSizeOfScreen(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from   ww  w  . j a  v a 2  s  .  co m
    return size;
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static Point getDisplayInfo(Context ctx) {
    Point info = new Point();
    WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getSize(info);
    ;/*from ww w  .  ja  v a2s . c o m*/
    return info;
}

From source file:Main.java

public static Point getDisplaySize(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    final Point size = new Point();
    display.getSize(size);/*from   w  ww. ja va 2s. com*/
    return size;
}

From source file:Main.java

public static Point getScreenSize(@Nullable Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);/* w w  w  .  j  a  va 2s . c  om*/
    return point;
}

From source file:Main.java

public static Point screenDisplay(Context activity) {
    DisplayMetrics metrics = activity.getResources().getDisplayMetrics();
    Point point = new Point();
    point.x = metrics.widthPixels;//from www .j  ava 2  s  .c  om
    return point;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    if (screenWidth != -1) {
        return screenWidth;
    }/*from  w w w  . jav  a 2 s .  c  o  m*/

    Point size = new Point();
    ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(size);

    screenWidth = size.x;
    return screenWidth;
}

From source file:Main.java

public static int getScreenHeight(Context context) {
    if (screenHeight != -1) {
        return screenHeight;
    }/*  w ww .  jav a2  s  . c o  m*/

    Point size = new Point();
    ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(size);

    screenHeight = size.y;
    return screenHeight;
}

From source file:Main.java

public static Point getDisplaySize(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);// w w w.j a  v  a 2s.c  o  m
    width = size.x;
    height = size.y;
    return size;
}

From source file:Main.java

public static Point getImageMaxDimension(Context context, int[] imgRes) {
    final Point point = new Point();

    for (int i = 0, length = imgRes.length; i < length; i++) {
        Bitmap tmp = BitmapFactory.decodeResource(context.getResources(), imgRes[i]);
        int width = tmp.getWidth();
        int height = tmp.getHeight();
        tmp.recycle();//from   w w  w  .  j  a v  a2s . c o m
        tmp = null;

        if (point.x < width) {
            point.x = width;
        }

        if (point.y < height) {
            point.y = height;
        }
    }

    return point;
}

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;/*www .j  ava  2s .  co  m*/
    } else {
        Display d = wm.getDefaultDisplay();
        Measuredwidth = d.getWidth();
    }

    return Measuredwidth;
}