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 getTop(Activity cont) {
    Rect frame = new Rect();
    cont.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    return frame.top;
}

From source file:Main.java

public static int getScreenHeight(Activity activity) {
    Rect out = new Rect();
    activity.getWindow().getDecorView().getHitRect(out);
    return out.height();
}

From source file:Main.java

public static int getStatusHeight(Activity activity) {
    Rect out = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(out);
    return out.top;
}

From source file:Main.java

public static int getTitleBarHeight(Activity cx) {
    Rect frame = new Rect();
    cx.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    return frame.top;
}

From source file:Main.java

public static Rect getRectInScreen(View view) {
    Rect rect = new Rect();
    int[] loc = new int[2];
    view.getLocationOnScreen(loc);//w w  w .ja  v  a2 s.  c  o m
    rect.left = loc[0];
    rect.top = loc[1];
    rect.right = loc[0] + view.getWidth();
    rect.bottom = loc[1] + view.getHeight();

    return rect;
}

From source file:Main.java

public static Rect getStatusBarInfo(Activity context) {
    Rect frame = new Rect();
    context.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    return frame;
}

From source file:Main.java

public static Rect measureText(Paint paint, String str) {
    Rect rect = new Rect();
    paint.getTextBounds(str, 0, str.length(), rect);
    return rect;/*from   w  ww  .  java 2s .c  om*/
}

From source file:Main.java

public static float getTextHeight(Paint paint) {
    Rect rectSizeText = new Rect();
    paint.getTextBounds("s", 0, "s".length(), rectSizeText);

    return paint.measureText("s");

}

From source file:Main.java

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

From source file:Main.java

public static boolean inViewInBounds(View view, int x, int y) {
    Rect outRect = new Rect();
    int[] location = new int[2];

    view.getDrawingRect(outRect);/*from w  w  w .  j  a  v  a 2 s  .c  om*/
    view.getLocationOnScreen(location);
    outRect.offset(location[0], location[1]);
    return outRect.contains(x, y);
}