如何在zing库中进行custum布局?

时间:2016-07-19 05:37:21

标签: android

我在qr代码扫描程序项目中工作。现在我需要为qr代码扫描程序创建custum布局是否可以使用zing?关于这个的任何教程/代码?

1 个答案:

答案 0 :(得分:0)

这里试试这个

 compile 'com.journeyapps:zxing-android-embedded:3.0.3@aar'
 compile 'com.google.zxing:core:3.2.0'


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<com.journeyapps.barcodescanner.CompoundBarcodeView
    android:id="@+id/barcode_scanner"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</com.journeyapps.barcodescanner.CompoundBarcodeView>

</LinearLayout>

在您的活动或片段中

 @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_page_three, container, false);
    barcodeView = (CompoundBarcodeView) view.findViewById(R.id.barcode_scanner);
    barcodeView.decodeContinuous(callback);

    return view;
}

回调

 private BarcodeCallback callback = new BarcodeCallback() {
    @Override
    public void barcodeResult(BarcodeResult result) {
    String resultString = result;
    }