TextView:

TextView is android widget for display any kind of text or strings.

Button:

Button is android widget for clickable touch events.Button can listen to click events.

Tutorial:

Step 1:

Open up Android Studio Project through res -> layout -> activity_main.xml (or) main.xml and add below code or just drag and drop the switch to design XML file.

Step 2:

Add below code in MainActivity.kt