gpt4 book ai didi

android - Zxing 使用自定义布局

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:07:48 25 4
gpt4 key购买 nike

我以这种方式使用 ZXing 库:

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'
}

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);
}
}

它看起来像这样: enter image description here

但我不知道如何在此相机预览上添加后退按钮。如何创建一个自定义布局,背景是摄像头,后退按钮在前面?

最佳答案

前段时间我遇到了这个问题,所以最后我从 Andreas Schildbach 那里借用并定制了代码 bitcoin wallet .当您有其他 View 时,这将在屏幕上创建一个小的相机 View 。

我把要点here .

它是一个 QRCode 扫描仪,周围有按钮和 EditText。它还具有一个覆盖矩形,以便更好地找到屏幕的中间。

关于android - Zxing 使用自定义布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27502023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com