Search code examples
androidcustomizationbarcodeqr-codezxing

How to Customize the capture screen border of zxing barcode scanner from ViewFinder


 <?xml version="1.0" encoding="utf-8"?>
<merge 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">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.journeyapps.barcodescanner.BarcodeView
            android:id="@+id/zxing_barcode_surface"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:zxing_framing_rect_height="220dp"
            app:zxing_framing_rect_width="250dp" />


        <com.journeyapps.barcodescanner.ViewfinderView
            android:id="@+id/zxing_viewfinder_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:zxing_possible_result_points="@color/zxing_custom_possible_result_points"
            app:zxing_result_view="@color/zxing_custom_result_view"
            app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
            app:zxing_viewfinder_mask="@color/zxing_custom_viewfinder_mask" />
    </RelativeLayout>

</merge>

I want to customize the capturing area of barcode and i am using the zxing embeded barcode so how shall i make the border of barcode area by my self. I just know that some changes would be don to ViewFinder class but the ViewFinder class is in library in jar library so how could i change it?

I just want to make the customize barcode border


Solution

  • Just set #00000000 as value of app:zxing_viewfinder_mask, and add an ImageView that contain the mask

    app:zxing_viewfinder_mask="#00000000"