Set layout
setContentView([Link].activity_main);
Connects Java code with activity_main.xml
Displays the UI on screen
Create a Bitmap
Bitmap bg = [Link](720, 1280, [Link].ARGB_8888);
Creates a blank image of size:
o Width: 720 px
o Height: 1280 px
ARGB_8888 → high-quality color format
ImageView and Button
ImageView i = (ImageView) findViewById([Link]);
Button b = (Button) findViewById([Link]);
Links Java objects with XML components
imageView → displays drawings
button → user clicks to draw shapes
✏️Canvas and Paint
Canvas c = new Canvas(bg);
Paint p = new Paint();
Canvas → drawing area over the bitmap
Paint → controls color, size, style of drawings
[Link](bg);
Shows the bitmap inside the ImageView
Button click event
[Link](new [Link]() {
Executes code when the button is clicked
🔴 Draw Text and Rectangle
[Link]([Link]);
[Link](35);
[Link]("Rectangle", 150, 350, p);
[Link](150, 150, 300, 300, p);
Sets paint color to red
Sets text size to 35
Draws:
o Text "Rectangle"
o Rectangle using coordinates:
Left: 150
Top: 150
Right: 300
Bottom: 300
🟢 Draw Circle
[Link]([Link]);
[Link](200, 100, 50, p);
Changes color to green
Draws a circle:
o Center → (200, 100)
o Radius → 50
🔵 Draw Lines
[Link]([Link]);
[Link](150,150,225,75,p);
[Link](225,75,300,150,p);
Sets color to blue
Draws two lines forming a triangle shape
✅ Final Output
When the button is clicked, the app draws:
🔴 A red rectangle and text
🟢 A green circle
🔵 Blue lines
All drawings appear inside the ImageView.