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.
Articoli simili
- Quali sono i pro e i contro dell'uso di un thumb draw rispetto al Mediterranean draw nel tiro con l'arco?
- What mobile games do you play daily and what keeps you coming back. If you could improve the game, what would you add?
- I'm in search of the best smartphone under Rs. 9000 in retail price with a very good camera, music player, and battery. Can you suggest me one?
- Do you watch anime and if so, which anime do you watch (sorry if you answered this already I'm new to Quora)?