Barcode-Reader
Barcode-Reader copied to clipboard
Green color in right side of camera preview
I solved this problem just added full screen mode in onCreate method:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Mee too
Mee too getting the same issue when fragment is resizing, Can you please respond to this query.Did any one solved this issue.
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>