Giter Site home page Giter Site logo

bgaqrcode-android's Introduction

🏃QRCode-Android🏃

License Maven Central

根据公司项目需求,参考这个项目改的 barcodescanner

主要功能:ZXing生成二维码、ZXing扫描二维码、ZBar扫描二维码(扫描中文会有乱码)、可控制闪光灯和定制各式各样的扫描框

效果图

Image of ZXingDemo Image of ZBarDemo Image of IqeggQRCodeDemo

点击下载ZXingDemo.apk或扫描下面的二维码安装 点击下载ZBarDemo apk或扫描下面的二维码安装
ZXingDemo apk文件二维码 ZBarDemo apk文件二维码

Gradle依赖

ZXing

dependencies {
    compile 'com.google.zxing:core:3.1.0'
    compile 'cn.bingoogolapple:qrcodecore:latestVersion@aar'
    compile 'cn.bingoogolapple:zxing:latestVersion@aar'
}

ZBar

dependencies {
    compile 'cn.bingoogolapple:qrcodecore:latestVersion@aar'
    compile 'cn.bingoogolapple:zbar:latestVersion@aar'
}

Layout

ZXing

<cn.bingoogolapple.qrcode.zxing.ZXingView
    android:id="@+id/zxingview"
    style="@style/MatchMatch"
    app:qrcv_cornerColor="@android:color/white"
    app:qrcv_cornerLength="20dp"
    app:qrcv_cornerSize="2dp"
    app:qrcv_maskColor="#33ffffff"
    app:qrcv_rectWidth="200dp"
    app:qrcv_scanLineColor="@android:color/white"
    app:qrcv_scanLineSize="1dp"
    app:qrcv_topOffset="80dp" />

ZBar

<cn.bingoogolapple.qrcode.zbar.ZBarView
    android:id="@+id/zbarview"
    style="@style/MatchMatch"
    app:qrcv_cornerColor="@color/colorPrimaryDark"
    app:qrcv_cornerLength="25dp"
    app:qrcv_cornerSize="3dp"
    app:qrcv_maskColor="#66ffffff"
    app:qrcv_rectWidth="220dp"
    app:qrcv_scanLineColor="@color/colorPrimary"
    app:qrcv_scanLineSize="2dp"
    app:qrcv_topOffset="90dp" />

自定义属性说明

属性名 说明 默认值
qrcv_topOffset 扫描框距离扫描视图顶部的距离 80dp
qrcv_cornerSize 扫描框边角线的宽度 2dp
qrcv_cornerLength 扫描框边角线的长度 20dp
qrcv_cornerColor 扫描框边角线的颜色 @android:color/white
qrcv_rectWidth 扫描框的宽度 200dp
qrcv_maskColor 除去扫描框,其余部分阴影颜色 #33ffffff
qrcv_scanLineSize 扫描线的宽度 1dp
qrcv_scanLineColor 扫描线的颜色 @android:color/white

接口说明

QRCodeView

/**
 * 显示扫描框
 */
public void showScanRect()

/**
 * 隐藏扫描框
 */
public void hiddenScanRect()

/**
 * 打开摄像头开始预览,但是并未开始识别
 */
public void startCamera()

/**
 * 关闭摄像头预览,并且隐藏扫描框
 */
public void stopCamera()

/**
 * 延迟1.5秒后开始识别
 */
public void startSpot()

/**
 * 延迟delay毫秒后开始识别
 *
 * @param delay
 */
public void startSpotDelay(int delay)

/**
 * 停止识别
 */
public void stopSpot()

/**
 * 停止识别,并且隐藏扫描框
 */
public void stopSpotAndHiddenRect()

/**
 * 显示扫描框,并且延迟1.5秒后开始识别
 */
public void startSpotAndShowRect()

/**
 * 打开闪光灯
 */
public void openFlashlight()

/**
 * 关闭散光灯
 */
public void closeFlashlight()

ResultHandler

/**
 * 处理扫描结果
 *
 * @param result
 */
void handleResult(String result)

/**
 * 处理打开相机出错
 */
void handleCameraError()

详细用法请查看ZBarDemo🐾

详细用法请查看ZXingDemo🐾

关于我

新浪微博 个人主页 邮箱 BGA系列开源库QQ群
bingoogolapple bingoogolapple.cn [email protected] BGA_CODE_CLUB

License

Copyright 2015 bingoogolapple

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

bgaqrcode-android's People

Contributors

bingoogolapple avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.