Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Green color in right side of camera preview #27

Open
mkhan9047 opened this issue Jan 15, 2019 · 3 comments
Open

Green color in right side of camera preview #27

mkhan9047 opened this issue Jan 15, 2019 · 3 comments

Comments

@mkhan9047
Copy link

No description provided.

@Rangel-Cristiano
Copy link

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

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

@Omegaki113r
Copy link

Mee too

@sivasankar0457
Copy link

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

@sivasankar0457
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants