Credntia / MVBarcodeReader

A Barcode scanner library for Android. Uses the Google Play Services' mobile vision api for barcode detection.
Apache License 2.0
68 stars 22 forks source link

Custom View with the scanner #9

Closed AugustoAleGon closed 7 years ago

AugustoAleGon commented 7 years ago

Hello.

I am using this amazing bar scanner and I thing is really great. I am happy with the results. Nevertheless I will like to custom the size of the scanner so then the user can see what exactly is focus on.

How can I achieve that purpose with the library?

In advance thank you so much for your help.

iamMehedi commented 7 years ago

The easiest way is to use the BarcodeCaptureFragment inside your own xml layout

<?xml version="1.0" encoding="utf-8"?>
<RealtiveLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <fragment android:name="devliving.online.mvbarcodereader.BarcodeCaptureFragment"
            android:id="@+id/scanner"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
</RelativeLayout>
AugustoAleGon commented 7 years ago

Ohh yes. You are totally right. I am gonna do it right know. I will test it and let you know how it goes.

AugustoAleGon commented 7 years ago

Hello Mehedi. I have a doubt with the Fragment. In order to use the scanner I have to do this piece of code right?: MVBarcodeScanner.ScanningMode mode = null; @MVBarcodeScanner.BarCodeFormat int[] formats = null;

BarcodeCaptureFragment fragment = BarcodeCaptureFragment.instantiate(mode, formats); getSupportFragmentManager().beginTransaction() .add(R.id.container, fragment) .commit();

the id.container is the id of the fragment?

iamMehedi commented 7 years ago

the R.id.container is the layout id of the parent layout