【发布时间】:2026-01-05 11:00:01
【问题描述】:
我已经使用JourneyApp's BarCode Scanner Library设置了条码扫描器
我添加了依赖项,就像在库的自述文件中一样。
然后,我像这样在我的主要活动中设置了条形码视图
main_activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<com.journeyapps.barcodescanner.BarcodeView
android:id="@+id/barcode_scanner"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.journeyapps.barcodescanner.BarcodeView>
</RelativeLayout>
我将 MainActivity.java 保留为默认值。这就是它的 OnCreate 方法
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
我也在清单中添加了相机权限。
当我在手机上运行应用程序时。 BarCodeView 仅显示黑屏。我在这里做错了吗?
【问题讨论】:
标签: java android zxing barcode-scanner