How do I make a rectangle using code in MIT app inventor?

using code blocks

On a canvas ?

(draggable blocks)

image

Or you could use two vertical arrangements, one inside the other....setting the inner one slightly smaller than the outer, with different colour backgrounds.

image