Zxing using custom layout

I use ZXingLibrary as follows:

repositories {
    mavenCentral()

    maven {
        url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.zxing:core:2.2'
    compile 'com.embarkmobile:zxing-android-minimal:1.2.1@aar'
}

And in Activity:

IntentIntegrator.initiateScan(this);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if(result != null) {
        if(result.getContents() == null) {
            Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
        }
    } else {
        // This is important, otherwise the result will not be passed to the fragment
        super.onActivityResult(requestCode, resultCode, data);
    }
}

And it looks like this: enter image description here

But I do not know how to add a button back to this camera preview. How to create a custom layout with a camera on the background and back on the front panel?

+4
source share
1 answer

I had this problem a while ago, so finally I borrowed and configured the code from Andreas Schildbach bitcoin wallet . This will create a small camera view on the screen as long as you have other views.

I put a gist here .

QRCode, EditText. , .

+4

All Articles