自定义相机视图和放大器;对于QR code在Zxing旋转? [英] Customized camera view & rotation in Zxing for QR code?
问题描述
我有这样一个伟大的图书馆zxing合作,以阅读QR code。我已经得到了QR code成功。
I am working with such a great library zxing to read QR code. I already got QR code successfully.
现在,在横向模式下我的应用程序运行和相机拍摄整个屏幕,红色的QR检测的矩形框的中间。我想改变这种以肖像模式和放大器;只有红色的QR检测的矩形框代替摄像机视图。
Now, My application runs in landscape mode and camera takes the whole screen and red QR detection rectangle box is in the middle. I wanna change this to portrait mode & replace the camera view only with the red QR detection rectangle box.
我改变CaptureActivity标签,它是zxing库清单文件中。
I change CaptureActivity tag which is inside the zxing library manifest file.
安卓screenOrientation =画像
但什么也没找到什么其实我想要的。我不知道我必须改变/写code得到这个。
But found nothing what I actually want. I don't know where I have to change/write code to get this.
推荐答案
我在同样的问题,被困2天左右就可以了。 其实你必须做一些工作来实现自己的目标。
I was in same problem and got stuck about 2 days on it. Actually you have to do some tasks to achieve your goal.
- 读取QR code下载Zxing库。(希望你已经)
- 创建一个项目并添加Zxing库。
-
您的main.xml文件应该是这样的:
- Download Zxing library for read QR code.. (Hope you have already)
- Create a project and add Zxing library.
Your main.xml file should look like:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal">
<include layout="@layout/capture"/>
</FrameLayout>
您的主要活动应该是这样的:
Your main Activity should look like:
公共类ScannerActivity扩展CaptureActivity {
public class ScannerActivity extends CaptureActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void handleDecode(Result rawResult, Bitmap barcode)
{
Toast.makeText(this.getApplicationContext(), "Scanned code " + rawResult.getText(), Toast.LENGTH_LONG).show();
}
}
在清单文件中添加下面的权限:
In the manifest file add permission following:
&LT; 使用-权限的Android:名称=android.permission.CAMERA/>
< uses-permission android:name="android.permission.CAMERA"/>
- 最后很重要的任务,你需要做的摄像头旋转问题,更换下面的方法到
CameraManager.java(在包com.google.zxing.client.android.camera)
CameraManager.java (in the package com.google.zxing.client.android.camera)
@SuppressLint("NewApi") public void startPreview() {
Camera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.setDisplayOrientation(90);
theCamera.startPreview();
previewing = true;
}
}
这就是全部。运行并享受: - )
that's all . run and enjoy :-)
感谢..
这篇关于自定义相机视图和放大器;对于QR code在Zxing旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!