Torch Switch Control#

Defined in package com.scandit.datacapture.core.ui.control

TorchSwitchControl#
class TorchSwitchControl : Control

Added in version 6.0.0

Control that allows to toggle the torch on an off. The torch switch control hides itself automatically in case the active frame source doesn’t have a torch.

You can add this control to a view by calling DataCaptureView.addControl().

TorchSwitchControl()#
TorchSwitchControl(@NonNull Context context)

Added in version 6.0.0

Constructor.

setImageResource(resId)#
void setImageResource(int resId)

Added in version 6.2.0

Sets a drawable to use as the image of this control.

Use XML drawable “selector” to indicate different states of this control. This control is considered “checked” when the torch is on. For example, this is a “selector” you may use to display different images when the torch is on and off:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/torch_on_icon"
        android:state_checked="true" />
    <item android:drawable="@drawable/torch_off_icon" />
</selector>