How do I add a rectangular overlay (which should be more like a rectangular frame) in the camera preview? My application consists of a button that opens the camera upon clicking
You have to create your own Preview by extending the SurfaceView class.
See below link which helps you.
Custom camera android
Take FrameLayout with SurfaceView as child.and customise as per your needs