Giter VIP home page Giter VIP logo

ezbar's Introduction

EZbar

Zbar二维码扫码器,贼简单

如何使用

Download

在工程gralde中加入

  implementation 'com.ccx1:EZbar:1.0.3'

在project的gradle中的allprojects中加入

    allprojects {
        repositories {
            google()
            jcenter()
            maven {url 'https://dl.bintray.com/ci250454344/EZbar/'}
        }
    }

在布局中添加ScannerView

     <ezbar.ccx.com.ezbarlib.ScannerView
            android:id="@+id/cameraPreview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

java代码

    mScannerView = (ScannerView) findViewById(R.id.cameraPreview);
    mScannerView.setOnParsingCompleteListener(new ParsingCompleteListener() {
        @Override
        public void onComplete(String text, String handingTime) {
            Toast.makeText(CameraTestActivity.this, "检测到扫描结果 : " + text + " , 消耗时间 :" + handingTime + " 秒", Toast.LENGTH_SHORT).show();
        }
    });

onComplete是扫码完成的回调

提供了一个设置扫码框大小的方法

    mScannerView.setScanWidthAndHeight(200);

提供了一个设置扫码框颜色的方法

    mScannerView.setScanRectColor(Color.RED);

提供了一个扫码结束之后重置的方法,非常关键

    mScannerView.reset();

在退出activity的时候要进行

    @Override
    protected void onDestroy() {
        mScannerView.release();
        super.onDestroy();
    }

打开闪光灯。

跟我写的zxing一样,true是打开,false是关闭

    mScannerView.openFlash(isOpen);

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.