0

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.

Thanks in advance. enter image description here

Nabin
  • 11,216
  • 8
  • 63
  • 98
CarinaMj
  • 187
  • 2
  • 14
  • https://stackoverflow.com/questions/15589379/customized-camera-view-rotation-in-zxing-for-qr-code?rq=1 – King of Masses Aug 10 '17 at 07:11
  • it will not helping to me... My question is always load the camera like the above attached image. – CarinaMj Aug 10 '17 at 07:20
  • @CarinaMj this link may help you https://stackoverflow.com/questions/18543668/integrate-zxing-in-android-studio – AskNilesh Aug 10 '17 at 07:23
  • I also used this ZXing SDK, I am asking that, Currently I have added the button to click then open CaptureActivity, But current design when I open this Activity then the top always camera will be opened and able to scan. – CarinaMj Aug 10 '17 at 08:16
  • Hi, How to design the camera inside my activity with the mentioned red color border. I have tried. but still not get the solution. – CarinaMj Sep 26 '17 at 03:05
  • @CarinaMj hi, have you got the solution for this design? – Arnold Brown Oct 01 '18 at 05:03

0 Answers0