Table of contents
Swift
Objective-C

Configure the Scan Region Style

Visibility

After you call setScanRegion, the scan region is visible by default. You can hide it by calling setScanRegionMaskVisible.

  • Java
  • Kotlin
  1. try {
       mCamera.setScanRegion(new DSRect(0.15f, 0.25f, 0.85f, 0.65f, true));
    } catch (CameraEnhancerException e) {
       throw new RuntimeException(e);
    }
    cameraView.setScanRegionMaskVisible(false);
    
  2. try {
       mCamera.setScanRegion(DSRect(0.15f, 0.25f, 0.85f, 0.65f, true))
    } catch (e: CameraEnhancerException) {
       throw RuntimeException(e)
    }
    cameraView.setScanRegionMaskVisible(false)
    

Scan Region Mask Style

The scan region mask style includes the stroke color, stroke width, and mask color.

scan-region-style

Scan Region Style

  1. Add your colors to res/values/colors.xml.
<color name="teal_200">#FF03DAC5</color>
<color name="teal_200_transparent">#2003DAC5</color>
  1. Set colors to the scan region mask style.
  • Java
  • Kotlin
  1. int teal_200_transparent = ResourcesCompat.getColor(MainActivity.this.getResources(), R.color.teal_200_transparent, null);
    int teal_200 = ResourcesCompat.getColor(MainActivity.this.getResources(), R.color.teal_200, null);
    cameraView.setScanRegionMaskStyle(teal_200, teal_200_transparent, 2.0f);
    
  2. val teal_200_transparent = ResourcesCompat.getColor(this@MainActivity.getResources(), R.color.teal_200_transparent, null)
    val teal_200 = ResourcesCompat.getColor(this@MainActivity.getResources(), R.color.teal_200, null)
    cameraView.setScanRegionMaskStyle(teal_200, teal_200_transparent, 2.0f)
    

Laser

The scan laser is a light bar that moves up and down to indicate active scanning. It does not affect performance. It is hidden by default. When a scan region is set, the laser movement is limited to that region.

  • Java
  • Kotlin
  1. cameraView.setScanLaserVisible(true);
    
  2. cameraView.setScanLaserVisible(true)
    

This page is compatible for: