Example usage for android.graphics Rect Rect

List of usage examples for android.graphics Rect Rect

Introduction

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

Prototype

public Rect() 

Source Link

Document

Create a new empty Rect.

Usage

From source file:Main.java

public static int getWindowHeight(Activity activity) {
    Rect out = new Rect();
    activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getHitRect(out);
    return out.height();
}

From source file:Main.java

public static int[] getApplicationWidthAndHeight(Activity activity) {
    Rect outRect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
    System.out.println("top:" + outRect.top + " ; left: " + outRect.left);
    int info[] = new int[2];
    info[0] = outRect.width();/* ww  w . j  ava 2  s .c om*/
    info[1] = outRect.height();
    return info;
}

From source file:Main.java

private static Rect getRectByByte(byte[] org) {
    Rect rect = new Rect();
    ByteBuffer byteBuffer = ByteBuffer.wrap(org).order(ByteOrder.nativeOrder());
    rect.set(byteBuffer.getInt(3 * 4), byteBuffer.getInt(5 * 4), byteBuffer.getInt(4 * 4),
            byteBuffer.getInt(6 * 4));//  ww w .ja v  a 2 s. com
    return rect;
}

From source file:Main.java

public static Rect getTextRec(String text, Paint paint, float textSize) {
    Rect rect = new Rect();
    if (paint != null && text != null) {
        if (0 < textSize) {
            paint.setTextSize(textSize);
        }//  ww w  .ja v a  2 s .c om
        paint.getTextBounds(text, 0, text.length(), rect);
    }
    return rect;
}

From source file:Main.java

public static int getStatusBarHeight(Context context) {
    Rect rect = new Rect();
    ((Activity) context).getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    return rect.top;
}

From source file:Main.java

public static int getStatusBarHeight(Activity context) {
    Rect rectangle = new Rect();
    Window window = context.getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
    return rectangle.top;
}

From source file:Main.java

public static int getStatusBarHeight(Context mContext) {
    Rect frame = new Rect();
    ((Activity) mContext).getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    return frame.top;
}

From source file:Main.java

public static int getStatusBarHeight(Activity activity) {
    Rect rectgle = new Rect();
    Window window = activity.getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
    int StatusBarHeight = rectgle.top;
    return StatusBarHeight;
}

From source file:Main.java

public static int[] sizeWithTitle(Activity activity) {
    Rect outRect = new Rect();
    int[] size = new int[2];
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
    size[0] = outRect.width();//  w  ww  .  j a va2s  .  co  m
    size[1] = outRect.height();
    return size;
}

From source file:Main.java

public static int getNotifyBarHeight(Activity context) {
    Rect frame;/*from w w  w  .  j  a  v  a  2  s .  co m*/
    try {
        frame = new Rect();
        context.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
        return frame.top;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}