I have to add the QRCode scan layout in my main layout than calling the new activity to load the camera to scan.
I already done that part using the ZXing library. So this I have created the layout like this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView
android:id="@+id/preview_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<zxing.ViewfinderView
android:id="@+id/viewfinder_view"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_centerInParent="true"
android:padding="10dp" />
<TextView
android:id="@+id/status_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/transparent"
android:text="@string/msg_default_status"
android:textColor="@color/status_text"
android:visibility="gone" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/viewfinder_view"
android:layout_gravity="bottom"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:text="Cancel"
android:visibility="gone" />
<!--</merge>-->
Then I called the CaptureActivity from ZXing Lib, If It's first time load the camera to scan then it will ask the permission and show this message. Sorry, the Android camera encountered a problem. You may need to restart the device. So 1. If I closed the camera then click the open camera button then it's working. 2. I need to create the custom layout for scanning like the below image screen.
