使用zxing-android-embedded做二维码扫描画面,去掉红线和闪光点的方法

1、新建一个ViewfinderView的子类,
public class YourViewFinder extends ViewfinderView {
 public YourViewFinder( Context context, AttributeSet attrs ) {
  super( context, attrs );
 }
 @SuppressLint("DrawAllocation")
 @Override
 public void onDraw( Canvas canvas ) {
  // 把ViewfinderView里的内容拷贝过来,然后把画线和画点的内容全去掉
 }
}

2、照着这个页面:
https://github.com/journeyapps/zxing-android-embedded/blob/master/sample/src/main/res/layout/custom_barcode_scanner.xml
新建一个custom_barcode_scanner.xml
注意:要把
com.journeyapps.barcodescanner.ViewfinderView
替换成你之前新建的那个ViewfinderView的子类

3、在你自己的扫描画面的layout中,这么写
<com.journeyapps.barcodescanner.DecoratedBarcodeView
 app:zxing_preview_scaling_strategy="centerCrop"
 app:zxing_use_texture_view="false"
 app:zxing_scanner_layout="@layout/custom_barcode_scanner"
 android:id="@+id/zxing_barcode_scanner"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />
注意这个:
app:zxing_scanner_layout="@layout/custom_barcode_scanner"

这样就可以了

以上

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容