The switch view operates differently depending on which version of Android you are using. This might cause an issue if your app is being run in older versions or newer versions. To solve this, instead we can use SwitchCompat
which operates the same on all versions currently.
To adjust this, go to xml code, instead of switch
// change from "Switch"
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/main_activity_sw_simulate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="9dp"
android:fontFamily="@font/coda"
android:text="@string/switch_text"
android:textColor="@color/onyx"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="TouchTargetSizeCheck" />
androidx.appcompat.widget.SwitchCompat
worked for me – Vitalism