public class RectF extends Object implements Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type  Field and Description 

float 
bottom 
static Parcelable.Creator<RectF> 
CREATOR 
float 
left 
float 
right 
float 
top 
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description 

RectF()
Create a new empty RectF.

RectF(float left,
float top,
float right,
float bottom)
Create a new rectangle with the specified coordinates.

RectF(Rect r) 
RectF(RectF r)
Create a new rectangle, initialized with the values in the specified
rectangle (which is left unmodified).

Modifier and Type  Method and Description 

float 
centerX() 
float 
centerY() 
boolean 
contains(float x,
float y)
Returns true if (x,y) is inside the rectangle.

boolean 
contains(float left,
float top,
float right,
float bottom)
Returns true iff the 4 specified sides of a rectangle are inside or equal
to this rectangle.

boolean 
contains(RectF r)
Returns true iff the specified rectangle r is inside or equal to this
rectangle.

int 
describeContents()
Parcelable interface methods

boolean 
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.

int 
hashCode()
Returns an integer hash code for this object.

float 
height() 
void 
inset(float dx,
float dy)
Inset the rectangle by (dx,dy).

boolean 
intersect(float left,
float top,
float right,
float bottom)
If the rectangle specified by left,top,right,bottom intersects this
rectangle, return true and set this rectangle to that intersection,
otherwise return false and do not change this rectangle.

boolean 
intersect(RectF r)
If the specified rectangle intersects this rectangle, return true and set
this rectangle to that intersection, otherwise return false and do not
change this rectangle.

boolean 
intersects(float left,
float top,
float right,
float bottom)
Returns true if this rectangle intersects the specified rectangle.

static boolean 
intersects(RectF a,
RectF b)
Returns true iff the two specified rectangles intersect.

boolean 
isEmpty()
Returns true if the rectangle is empty (left >= right or top >= bottom)

void 
offset(float dx,
float dy)
Offset the rectangle by adding dx to its left and right coordinates, and
adding dy to its top and bottom coordinates.

void 
offsetTo(float newLeft,
float newTop)
Offset the rectangle to a specific (left, top) position,
keeping its width and height the same.

void 
printShortString(PrintWriter pw)
Print short representation to given writer.

void 
readFromParcel(Parcel in)
Set the rectangle's coordinates from the data stored in the specified
parcel.

void 
round(Rect dst)
Set the dst integer Rect by rounding this rectangle's coordinates
to their nearest integer values.

void 
roundOut(Rect dst)
Set the dst integer Rect by rounding "out" this rectangle, choosing the
floor of top and left, and the ceiling of right and bottom.

void 
set(float left,
float top,
float right,
float bottom)
Set the rectangle's coordinates to the specified values.

void 
set(Rect src)
Copy the coordinates from src into this rectangle.

void 
set(RectF src)
Copy the coordinates from src into this rectangle.

void 
setEmpty()
Set the rectangle to (0,0,0,0)

boolean 
setIntersect(RectF a,
RectF b)
If rectangles a and b intersect, return true and set this rectangle to
that intersection, otherwise return false and do not change this
rectangle.

void 
sort()
Swap top/bottom or left/right if there are flipped (i.e.

String 
toShortString()
Return a string representation of the rectangle in a compact form.

String 
toShortString(StringBuilder sb)
Return a string representation of the rectangle in a compact form.

String 
toString()
Returns a string containing a concise, humanreadable description of this
object.

void 
union(float x,
float y)
Update this Rect to enclose itself and the [x,y] coordinate.

void 
union(float left,
float top,
float right,
float bottom)
Update this Rect to enclose itself and the specified rectangle.

void 
union(RectF r)
Update this Rect to enclose itself and the specified rectangle.

float 
width() 
void 
writeToParcel(Parcel out,
int flags)
Write this rectangle to the specified parcel.

public float left
public float top
public float right
public float bottom
public static final Parcelable.Creator<RectF> CREATOR
public RectF()
public RectF(float left, float top, float right, float bottom)
left
 The X coordinate of the left side of the rectangletop
 The Y coordinate of the top of the rectangleright
 The X coordinate of the right side of the rectanglebottom
 The Y coordinate of the bottom of the rectanglepublic RectF(RectF r)
r
 The rectangle whose coordinates are copied into the new
rectangle.public RectF(Rect r)
public boolean equals(Object o)
Object
o
must represent the same object
as this instance using a classspecific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and Object.hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
equals
in class Object
o
 the object to compare this instance with.true
if the specified object is equal to this Object
; false
otherwise.Object.hashCode()
public int hashCode()
Object
Object.equals(java.lang.Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)
public String toString()
Object
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
public String toShortString()
public String toShortString(StringBuilder sb)
public void printShortString(PrintWriter pw)
public final boolean isEmpty()
public final float width()
public final float height()
public final float centerX()
public final float centerY()
public void setEmpty()
public void set(float left, float top, float right, float bottom)
left
 The X coordinate of the left side of the rectangletop
 The Y coordinate of the top of the rectangleright
 The X coordinate of the right side of the rectanglebottom
 The Y coordinate of the bottom of the rectanglepublic void set(RectF src)
src
 The rectangle whose coordinates are copied into this
rectangle.public void set(Rect src)
src
 The rectangle whose coordinates are copied into this
rectangle.public void offset(float dx, float dy)
dx
 The amount to add to the rectangle's left and right coordinatesdy
 The amount to add to the rectangle's top and bottom coordinatespublic void offsetTo(float newLeft, float newTop)
newLeft
 The new "left" coordinate for the rectanglenewTop
 The new "top" coordinate for the rectanglepublic void inset(float dx, float dy)
dx
 The amount to add(subtract) from the rectangle's left(right)dy
 The amount to add(subtract) from the rectangle's top(bottom)public boolean contains(float x, float y)
x
 The X coordinate of the point being tested for containmenty
 The Y coordinate of the point being tested for containmentpublic boolean contains(float left, float top, float right, float bottom)
left
 The left side of the rectangle being tested for containmenttop
 The top of the rectangle being tested for containmentright
 The right side of the rectangle being tested for containmentbottom
 The bottom of the rectangle being tested for containmentpublic boolean contains(RectF r)
r
 The rectangle being tested for containment.public boolean intersect(float left, float top, float right, float bottom)
left
 The left side of the rectangle being intersected with this
rectangletop
 The top of the rectangle being intersected with this rectangleright
 The right side of the rectangle being intersected with this
rectangle.bottom
 The bottom of the rectangle being intersected with this
rectangle.public boolean intersect(RectF r)
r
 The rectangle being intersected with this rectangle.public boolean setIntersect(RectF a, RectF b)
a
 The first rectangle being intersected withb
 The second rectangle being intersected withpublic boolean intersects(float left, float top, float right, float bottom)
left
 The left side of the rectangle being tested for intersectiontop
 The top of the rectangle being tested for intersectionright
 The right side of the rectangle being tested for
intersectionbottom
 The bottom of the rectangle being tested for intersectionpublic static boolean intersects(RectF a, RectF b)
a
 The first rectangle being tested for intersectionb
 The second rectangle being tested for intersectionpublic void round(Rect dst)
public void roundOut(Rect dst)
public void union(float left, float top, float right, float bottom)
left
 The left edge being unioned with this rectangletop
 The top edge being unioned with this rectangleright
 The right edge being unioned with this rectanglebottom
 The bottom edge being unioned with this rectanglepublic void union(RectF r)
r
 The rectangle being unioned with this rectanglepublic void union(float x, float y)
x
 The x coordinate of the point to add to the rectangley
 The y coordinate of the point to add to the rectanglepublic void sort()
public int describeContents()
describeContents
in interface Parcelable
public void writeToParcel(Parcel out, int flags)
writeToParcel
in interface Parcelable
out
 The parcel to write the rectangle's coordinates intoflags
 Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public void readFromParcel(Parcel in)
in
 The parcel to read the rectangle's coordinates from