Barcode-Reader icon indicating copy to clipboard operation
Barcode-Reader copied to clipboard

Green color in right side of camera preview

Open mkhan9047 opened this issue 5 years ago • 3 comments

mkhan9047 avatar Jan 15 '19 05:01 mkhan9047

I solved this problem just added full screen mode in onCreate method:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Rangel-Cristiano avatar Jun 02 '19 16:06 Rangel-Cristiano

Mee too

Omegaki113r avatar Jun 06 '19 18:06 Omegaki113r

Mee too getting the same issue when fragment is resizing, Can you please respond to this query.Did any one solved this issue.

sivasankar0457 avatar Sep 07 '19 15:09 sivasankar0457

Issue solved change in barcode library in CameraSourcePreview file in OnLayout overridden method with

@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { int width = 400; int height = 240; if (mCameraSource != null) { Size size = mCameraSource.getPreviewSize(); if (size != null) { width = size.getWidth(); height = size.getHeight(); } }

    // Swap width and height sizes when in portrait, since it will be rotated 90 degrees
    if (isPortraitMode()) {
        int tmp = width;

        //noinspection SuspiciousNameCombination
        width = height;
        height = tmp;
    }

    final int layoutWidth = right - left;
    final int layoutHeight = bottom - top;

    // Computes height and width for potentially doing fit width.
    int childWidth = layoutWidth;
    int childHeight = (int) (((float) layoutWidth / (float) width) * height);

    for (int i = 0; i < getChildCount(); ++i) {
        getChildAt(i).layout(0, 0, childWidth, layoutHeight);
    }

    try {
        startIfReady();
    } catch (SecurityException se) {
        Log.e(TAG, "Do not have permission to start the camera", se);
    } catch (IOException e) {
        Log.e(TAG, "Could not start camera source.", e);
    }
}  

And also adjust layout size in xml file which is located in BarcodeReader class XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/topLayout" android:layout_width="fill_parent" android:layout_height="180dp" android:background="#ffffff" android:keepScreenOn="true" android:orientation="vertical">

<info.androidhive.barcode.camera.CameraSourcePreview
    android:id="@+id/preview"
    android:layout_width="match_parent"
    android:layout_height="180dp">

    <info.androidhive.barcode.camera.GraphicOverlay
        android:id="@+id/graphicOverlay"
        android:layout_width="match_parent"
        android:layout_height="180dp" />
</info.androidhive.barcode.camera.CameraSourcePreview>

sivasankar0457 avatar Sep 07 '19 16:09 sivasankar0457