Search code examples
androidxmllayoutviewbarcode-scanner

Zbar add floating View


Ok, so, i want to make something like this: http://postimg.org/image/qs3okxitf/

Now, im using zbarscannerview like this:

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

and my xml is:

<?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>

What I dont understand is how to add the image(text from the screenshot) as a child view for my zbarscannerView.


Solution

  • Check out their rapository on github, they have something there.