-
Notifications
You must be signed in to change notification settings - Fork 7
Home
leo edited this page May 5, 2019
·
12 revisions
Welcome to the ZxingView wiki!
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
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"
/>
remind:
You can set any size and aspect ratio without distortion.
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);
}
});
<cn.leo.produce.ZxingView
android:id="@+id/zxingView"
android:layout_width="match_parent"
android:layout_height="match_parent"
// customize the Identification area
app:recognizeRectWidthInDp="270"
app:recognizeRectHeightInDp="270"
// customize the default Interactive View
app:interactiveViewColor="#118eea"
app:interactiveViewMaskColor="#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 |
interactiveViewColor | string | the Identification area default style color |
interactiveViewMaskColor | 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.
<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"
// customize the Identification area
app:recognizeRectWidthInDp="270"
app:recognizeRectHeightInDp="270"
/>
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.
the Identification area automatic center in zxingview.