首先导入zxing库,打开app下的build.gradle位置如下。
打开后在如下位置后,在dependencies中
添加划线的那行代码,即:
compile 'com.journeyapps:zxing-android-embedded:3.5.0'
解析条形码
1.在xml中写入控件,我这里是一个TextView用来接收返回的ISBN码和一个Button用来触发扫码事件
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:paddingTop="10dp" android:paddingLeft="30dp" android:textSize="25dp" android:id="@+id/isbn"/> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:layout_alignParentRight="true" android:text="扫一扫" />