Rect rect = new Rect(0, 0, 200, 100); int centerY = rect.centerY();
Rect rect = new Rect(0, 0, 200, 100); rect.centerY(50);In this example, a new Rect object is created with the coordinates (0, 0, 200, 100). The centerY property is then called on the Rect object with a value of 50 to set the center Y coordinate of the rectangle to 50. Package library: android.graphics.