Android ToggleButton
ToggleButton:
ToggleButton is a user interface detail that represents a two-state button, permitting users to toggle among two states—commonly an "on" state and an "off" state.
The visual representation of a ToggleButton typically includes a transfer-like look, indicating whether the toggle is currently within the energetic or inactive state.
Example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ToggleButtonExample"
android:orientation="vertical"
android:gravity="center">
<ToggleButton
android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/cyan"/>
</LinearLayout>
Output