Rect Rect Class

Definition

Rect holds four integer coordinates for a rectangle.

[Android.Runtime.Register("android/graphics/Rect", ApiSince=1, DoNotGenerateAcw=true)]
public sealed class Rect : Java.Lang.Object, Android.OS.IParcelable, IDisposable
type Rect = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
Inheritance
Attributes
Implements

Remarks

Android platform documentation

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Rect() Rect()

Create a new empty Rect.

Rect(Int32, Int32, Int32, Int32) Rect(Int32, Int32, Int32, Int32)

Create a new rectangle with the specified coordinates.

Rect(Rect) Rect(Rect)

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

Properties

Bottom Bottom
Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
Creator Creator
Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
IsEmpty IsEmpty

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

JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
Left Left
PeerReference PeerReference Inherited from Object
Right Right
ThresholdClass ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
Top Top

Methods

CenterX() CenterX()
CenterY() CenterY()
Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
Contains(Int32, Int32) Contains(Int32, Int32)

Returns true if (x,y) is inside the rectangle.

Contains(Int32, Int32, Int32, Int32) Contains(Int32, Int32, Int32, Int32)

Returns true iff the 4 specified sides of a rectangle are inside or equal to this rectangle. i.e. is this rectangle a superset of the specified rectangle.

Contains(Rect) Contains(Rect)

Returns true iff the specified rectangle r is inside or equal to this rectangle.

DescribeContents() DescribeContents()

Parcelable interface methods

Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
ExactCenterX() ExactCenterX()
ExactCenterY() ExactCenterY()
FlattenToString() FlattenToString()

Return a string representation of the rectangle in a well-defined format.

GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
Height() Height()
Inset(Int32, Int32) Inset(Int32, Int32)

Inset the rectangle by (dx,dy).

Intersect(Int32, Int32, Int32, Int32) Intersect(Int32, Int32, Int32, Int32)

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.

Intersect(Rect) Intersect(Rect)

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.

Intersects(Int32, Int32, Int32, Int32) Intersects(Int32, Int32, Int32, Int32)

Returns true if this rectangle intersects the specified rectangle.

Intersects(Rect, Rect) Intersects(Rect, Rect)

Returns true iff the two specified rectangles intersect.

JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
Offset(Int32, Int32) Offset(Int32, Int32)

Offset the rectangle by adding dx to its left and right coordinates, and adding dy to its top and bottom coordinates.

OffsetTo(Int32, Int32) OffsetTo(Int32, Int32)

Offset the rectangle to a specific (left, top) position, keeping its width and height the same.

ReadFromParcel(Parcel) ReadFromParcel(Parcel)

Set the rectangle's coordinates from the data stored in the specified parcel.

Set(Int32, Int32, Int32, Int32) Set(Int32, Int32, Int32, Int32)

Set the rectangle's coordinates to the specified values.

Set(Rect) Set(Rect)

Copy the coordinates from src into this rectangle.

SetEmpty() SetEmpty()

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

SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetIntersect(Rect, Rect) SetIntersect(Rect, Rect)

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

Sort() Sort()

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

ToArray<T>() ToArray<T>() Inherited from Object
ToShortString() ToShortString()

Return a string representation of the rectangle in a compact form.

ToString() ToString()

Returns a string containing a concise, human-readable description of this object.

(Inherited from Object)
UnflattenFromString(String) UnflattenFromString(String)

Returns a Rect from a string of the form returned by FlattenToString(), or null if the string is not of that form.

Union(Int32, Int32) Union(Int32, Int32)

Update this Rect to enclose itself and the [x,y] coordinate.

Union(Int32, Int32, Int32, Int32) Union(Int32, Int32, Int32, Int32)

Update this Rect to enclose itself and the specified rectangle.

Union(Rect) Union(Rect)

Update this Rect to enclose itself and the specified rectangle.

UnregisterFromRuntime() UnregisterFromRuntime() Inherited from Object
Wait() Wait()

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Width() Width()
WriteToParcel(Parcel, ParcelableWriteFlags) WriteToParcel(Parcel, ParcelableWriteFlags)

Write this rectangle to the specified parcel.

Explicit Interface Implementations

IJavaObjectEx.ToLocalJniHandle() IJavaObjectEx.ToLocalJniHandle() Inherited from Object
IJavaPeerable.Disposed() IJavaPeerable.Disposed() Inherited from Object
IJavaPeerable.DisposeUnlessReferenced() IJavaPeerable.DisposeUnlessReferenced() Inherited from Object
IJavaPeerable.Finalized() IJavaPeerable.Finalized() Inherited from Object
IJavaPeerable.SetJniIdentityHashCode(Int32) IJavaPeerable.SetJniIdentityHashCode(Int32) Inherited from Object
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) Inherited from Object
IJavaPeerable.SetPeerReference(JniObjectReference) IJavaPeerable.SetPeerReference(JniObjectReference) Inherited from Object

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to