需要注意的是这里使用的
CameraManager是zxing里面的。
import com.example.wechat.zxing.camera.CameraManager;
<?xml version="1.0" encoding="utf-8"?>这里用了一个 SurfaceView
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<SurfaceView
android:id="@+id/preview_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<com.juns.wechat.zxing.view.ViewfinderView
android:id="@+id/viewfinder_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<RelativeLayout
android:id="@+id/layout_title"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/bar_color" >
<ImageView
android:id="@+id/img_back"
android:layout_centerVertical="true"
android:layout_width="50dp"
android:layout_height="20dp"
android:contentDescription="@string/app_name"
android:src="@drawable/icon_back" />
<TextView
android:id="@+id/common_title_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#999999"
android:textSize="22sp" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="请将二维码置于取景框内,即可自动扫描"
android:textColor="@color/gray"
android:textSize="16sp" />
</RelativeLayout>
</FrameLayout>