可以访问Zxing QR扫描仪摄像机视图 [英] Get access to Zxing QR scanner camera view

查看:598
本文介绍了可以访问Zxing QR扫描仪摄像机视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新android开发,我的工作在Android项目中,我必须整合QR扫描仪。所以,我想我会整合Zxing QR扫描仪和碰到这个库 https://github.com/dm77 /条codescanner ,按照提供的说明,我已经成功地和一个扫描QR为好。 现在,我想自定义相机视图​​。问题是,对于如何获得访问摄像头的布局没有文档。由于我是新的我可能失去了一些东西。

I am new to android development and I am working on an android project where I have to integrate QR scanner. So I thought I would integrate Zxing QR scanner and came across this library https://github.com/dm77/barcodescanner, Following the instructions provided I have successfully integrated and scanned a QR as well. Now I want to customise the camera view. The problem is there is no documentation on how to get access to the camera layout. Since I am new I might be missing something.

我已经经历了很多Zxing相关的线程读取,但我DIN找到任何解决方案。

I have read through many Zxing related threads but I din find any solution.

任何帮助将大大AP preciated无论是让我知道我如何可以访问摄像机视图或指向我出去一些文章。有一次,我知道我就可以完成其余部分。

Any help will be greatly appreciated either by letting me know on how I can get access to the camera view or pointing me out to some articles. Once I know how then I can complete the rest.

我会很乐意提供任何进一步的信息。

I would be happy to provide any further information.

在此先感谢。

更新:

public class QrScanActivity extends BaseActivity implements ZXingScannerView.ResultHandler {
    private ZXingScannerView mScannerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_scan);

        // Programmatically initialize the scanner view
        mScannerView = new ZXingScannerView(this);
        // Set the scanner view as the content view
        setContentView(mScannerView);
    }

mScannerView 是从库中查看。我想访问该视图。我有一个称为 activity_my_scan 视图。我可以添加自定义布局,这和使用,但我不知道如何绕过布局正在使用的库。

mScannerView is the view from the library. I want to get access to that view. I have a view called as activity_my_scan. I can add custom layout to that and use that but I don't know how to bypass the layout being used by the library.

推荐答案

ZXingScannerView延伸吧codeScannerView。你可以去ZXingScannerView的声明(在Android的工作室按Ctrl + B)访问此。

ZXingScannerView extends BarcodeScannerView. You can access this by going to the declaration of ZXingScannerView (in Android Studio Ctrl+B).

public class ZXingScannerView extends BarcodeScannerView {
private MultiFormatReader mMultiFormatReader;
public static final List<BarcodeFormat> ALL_FORMATS = new ArrayList();
private List<BarcodeFormat> mFormats;
private ZXingScannerView.ResultHandler mResultHandler;

如果你去的吧codeScannerView的声明,你会发现)呼吁setupLayout(一种方法,它格式化布局:

If you go the declaration of BarcodeScannerView, you'll notice a method called setupLayout() which formats the layout:

public void setupLayout() {
    this.mPreview = new CameraPreview(this.getContext());
    this.mViewFinderView = new ViewFinderView(this.getContext());
    RelativeLayout relativeLayout = new RelativeLayout(this.getContext());
    relativeLayout.setGravity(17);
    relativeLayout.setBackgroundColor(-16777216);
    relativeLayout.addView(this.mPreview);
    this.addView(relativeLayout);
    this.addView(this.mViewFinderView);
}

通过将的摄像头preVIEW的宣言,你就可以得到更多的信息在相机的布局方式,你也许可以延长ZXingScannerView编辑布局。

By going to the declaration of "CameraPreview" you'll be able to get more info for how the camera is laid out and you could maybe extend ZXingScannerView to edit the layout.

希望这有助于!

干杯!

这篇关于可以访问Zxing QR扫描仪摄像机视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆