A switch is a two state toggle switch widget that can select between two options. The user may drag the thumb back and forth to choose the selected option, or simply tap to toggle as if it were a checkbox.
Source code:
avandrewmaterials.blogspot.in/2017/02/android-switch-button-tutorial.html