Rect rect = new Rect(0, 0, 100, 100); // Creates a rectangle with coordinates (0, 0) to (100, 100) rect.inset(10, 10); // Increases the size of the rectangle by 10 pixels on each edge
Rect rect = new Rect(0, 0, 100, 100); // Creates a rectangle with coordinates (0, 0) to (100, 100) rect.inset(20, 20); // Shrinks the rectangle by 20 pixels on each edge canvas.clipRect(rect); // Sets the canvas to only draw within the clipped region of the rectangleBoth examples use the android.graphics.Rect class and the inset() method to modify the rectangle. The package library is "android.graphics".