Table of contents
Swift
Objective-C

Customize Overlay with DrawingItems

CameraView allows you to define your own graphics diplaying rules with the Drawing APIs.

  • DrawingItem: Graphics or other UI elements.
  • DrawingLayer: The layer for displaying the DrawingItems.
  • DrawingStyle: The style for the DrawingItem.

Hide Barcode Highlight Overlay

Barcode highlight overlay is displayed by default. You can set the layer invisible to disable it:

  • Java
  • Kotlin
  1. // Get the layer first.
    DrawingLayer layer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID);
    // Set the visible property to true or false to control the visibility.
    layer.setVisible(false);
    
  2. // Get the layer first.
    val layer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID)
    // Set the visible property to true or false to control the visibility.
    layer.setVisible(false)
    

Add User-Define DrawingItem(s)

  • Java
  • Kotlin
  1. DrawingLayer barcodeLayer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID);
    ArrayList<DrawingItem> drawingItemArrayList = new ArrayList<>();
    QuadDrawingItem quadDrawingItem = new QuadDrawingItem(...);
    drawingItemArrayList.add(quadDrawingItem);
    barcodeLayer.setDrawingItems(drawingItemArrayList);
    // You can also use the append logic if you don't want to clear the previous items.
    // barcodeLayer.addDrawingItems(drawingItemArrayList);
    
  2. val barcodeLayer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID)
    val drawingItemArrayList = ArrayList<DrawingItem>()
    val quadDrawingItem = QuadDrawingItem(...)
    drawingItemArrayList.add(quadDrawingItem)
    barcodeLayer.setDrawingItems(drawingItemArrayList)
    // You can also use the append logic if you don't want to clear the previous items.
    // barcodeLayer.addDrawingItems(drawingItemArrayList)
    

How to Change the DrawingStyle

Use Preset Styles

Set the style of the highlight overlays with a preset style:

  • Java
  • Kotlin
  1. // Get the layer first.
    DrawingLayer layer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID);
    // Change the style of the layer.
    layer.setDefaultStyle(DrawingStyleManager.STYLE_BLUE_STROKE);
    
  2. // Get the layer first.
    val layer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID)
    // Change the style of the layer.
    layer.setDefaultStyle(DrawingStyleManager.STYLE_BLUE_STROKE)
    

Use User Defined Styles

Set the style of the highlight overlays with a user defined style:

  1. Create colours in the values/colours.xml file.

     <color name="teal_200">#FF03DAC5</color>
     <color name="teal_200_transparent">#2003DAC5</color>
    
  2. Create your style with the colour and set to the layer.

    • Java
    • Kotlin
    1.  // Get the layer first.
       DrawingLayer layer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID);
       // Create a new DrawingStyle via the DrawingStyleManager.
       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);
       int style = DrawingStyleManager.createDrawingStyle(teal_200, 1.0f,teal_200_transparent,teal_200);
       // Set the newly created DrawingStyle to the layer.
       layer.setDefaultStyle(style);
      
    2.  val layer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID)
       // Create a new DrawingStyle via the DrawingStyleManager.
       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)
       val style = DrawingStyleManager.createDrawingStyle(teal_200, 1.0f, teal_200_transparent, teal_200)
       // Set the newly created DrawingStyle to the layer.
       layer.setDefaultStyle(style)
      

This page is compatible for: