android.graphics.Rect is a class that is part of the Android Graphics package library. It is used to store and manipulate rectangular shapes. The Rect class has four integer properties that define the position and size of the rectangle: left, top, right, and bottom.
Code Example 1:
// Create a new Rect object with default values Rect rect = new Rect();
// Set the values of a Rect object rect.left = 10; rect.top = 20; rect.right = 100; rect.bottom = 200;
// Draw the Rect object on a Canvas canvas.drawRect(rect, paint);
Description: In this example, we create a new Rect object with default values and then set the values of the left, top, right and bottom properties. Finally, we use the rect object to draw a rectangle on a Canvas object.
Code Example 2:
// Create a new Rect object using constructor Rect rect = new Rect(10, 20, 100, 200);
// Check if the Rect object contains a point if(rect.contains(50, 150)){ // point (50, 150) is inside the rectangle }
Description: In this example, we use the constructor to create a new Rect object with specific values for the left, top, right, and bottom properties. Then, we use the contains() method to check if a point (50,150) is inside the rectangle.
Package Library: android.graphics
Java Rect.right - 30 examples found. These are the top rated real world Java examples of android.graphics.Rect.right extracted from open source projects. You can rate examples to help us improve the quality of examples.