Skip to content
leo edited this page Apr 25, 2019 · 12 revisions

Welcome to the ZxingView wiki!

1. Getting started

Step 1. Add it in your root build.gradle :

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

        dependencies {
           implementation 'com.github.fanrunqi:ZxingView:VERSION_CODE'
	}

Click here to view the latest VERSION_CODE

2. Quick use

Step 1. Configure your scan code Activity manifest Attributes

If you need to rotate, add this:

android:configChanges="orientation|screenSize|screenLayout"

or lock screen Orientation:

android:screenOrientation="portrait"  // landscape

Step 2. Add layout

  <cn.leo.produce.ZxingView
        android:id="@+id/zxingView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

Step 3. add code for the results

ZxingView zxingView = findViewById(R.id.zxingView);
zxingView.bind(this)
         .subscribe(new ResultCallBack() {
             @Override
             public void onResult(String result) {
                Log.i(TAG, "onResult:" + result);
             }
         });

3. Customize Interactive View(the Animation view)

  <cn.leo.produce.ZxingView
        android:id="@+id/zxingView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        // customize Attributes below

        app:recognizeRectWidthInDp="270"
        app:recognizeRectHeightInDp="270"
        app:defaultViewFinderColor="#118eea"
        app:defaultViewFinderMaskColor="#a0000000"
        />

The property description as follows:

Attributes Type significance
recognizeRectWidthInDp integer the width of the Identification area
recognizeRectHeightInDp integer the height of the Identification area
defaultViewFinderColor string the Identification area element color
defaultViewFinderMaskColor string the mask area color

remind:If the recognition area > the zxingview area or the recognition area <= zero, it will set the recognition area = the zxingview area.

4. Use your own Interactive View

  <cn.leo.produce.ZxingView
        android:id="@+id/zxingView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        // Do not use Default Interactive View

        app:useDefaultInteractiveView="false"
        />

The property description as follow:

Attributes Type significance
useDefaultInteractiveView boolean use or not the Default Interactive View(Default is true)

then:add your own interactive view in your laout.xml

remind:your own interactive view should adapt the Identification area.

Give me a support, Thank you !

Clone this wiki locally