QNA > H > How To Draw Corners Of Rectangle On The Camera Preview In Android? Can You Share A Code Sample For The Same

How to draw corners of rectangle on the camera preview in Android? Can you share a code sample for the same

To acchieve this you can just put your camera preview into a FrameLayout and place a transparent View with this rect inside above the camera preview.

First we are going to create the rectangle:

<?xml version="1.0" encoding="utf-8"?>

android:shape="rectangle">

android:width="1dp"

android:color="@color/white"

android:dashGap="8dp"

android:dashWidth="8dp" />

Then you can put this view over your preview:

<?xml version="1.0" encoding="utf-8"?>

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="match_parent" />

android:layout_width="match_parent"

android:layout_height="match_parent"

padding="32dp"

android:background="@drawable/your_shape" />

EDIT:

after taking a look at your layout the task can be solved by just placing htis view:

padding="32dp"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_above="@id/record_panel"

android:layout_alignParentTop="true"

android:background="@drawable/your_shape" />

as last item of the layout with the id cameraLayout.

Di Treva Immediato

Si può usare un telefono come tavoletta da disegno? :: Perché la televisione via cavo sta facendo meglio delle emittenti via etere?
Link utili