Zbar添加浮动视图



好的,我想做这样的东西:http://postimg.org/image/qs3okxitf/

现在,我像这样使用zbarscannerview:

public class BarKodScreen extends AppCompatActivity implements ZBarScannerView.ResultHandler {
private ZBarScannerView mView;
private BarcodeFormat barcodeFormatEAN13, barcodeFormatEAN8;
private List<BarcodeFormat> listaZaFormat = new ArrayList<BarcodeFormat>();
private ImageView img;
private LinearLayout lejout;
private View kamera;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_barkod);
    mView = new ZBarScannerView(this);
    lejout = (LinearLayout) findViewById(R.id.cameraPreview);
    img = (ImageView) findViewById(R.id.cameraImageView);
    kamera = (View) findViewById(R.id.zaKameru);
    kamera = mView;
    lejout.addView(kamera);
    lejout.addView(kamera);
    lejout.removeView(img);
    lejout.addView(img);

    barcodeFormatEAN13 = BarcodeFormat.EAN13;
    barcodeFormatEAN8 = BarcodeFormat.EAN8;
    listaZaFormat.add(barcodeFormatEAN13);
    listaZaFormat.add(barcodeFormatEAN8);
    mView.setFormats(listaZaFormat);
}

@Override
public void onResume() {
    super.onResume();
    mView.setResultHandler(this); // Register ourselves as a handler for scan results.
    mView.startCamera();          // Start camera on resume
}
@Override
public void onPause() {
    super.onPause();
    mView.stopCamera();           // Stop camera on pause
}
@Override
public void handleResult(Result rawResult) {
    // Do something with the result here
    Log.v("GetCOntent", rawResult.getContents()); // Prints scan results
    barKodZahtev(rawResult.getContents());
}
}

和我的XML是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/cameraPreview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <View
        android:id="@+id/zaKameru"
        android:layout_width="match_parent"
        android:layout_height="150dp"/>
    <ImageView
        android:id="@+id/cameraImageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="0.6"
        android:src="@drawable/share" />

</LinearLayout>

我不明白的是如何添加图像(来自屏幕截图的文本)作为我的zbarscannerView的子视图。

在github上查看他们的仓库,那里有一些东西

最新更新