Hide default text for android switch Button

android, button, switch-statement

Solution

For lower version, to hide the text use

 <Switch
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="7dp"
            android:textOff=""
            android:textOn=""
            android:background="@drawable/offbuttonbg"
            android:textAppearance="@style/SwitchTextAppearance"
            android:thumb="@drawable/switchselector" />

Problem

In my Android application I have used a Switch Button. Is there anyway to hide text of switch button? For API level 21 there is an option to hide (android:showText), but I need to run it on lower level devices. Here is my xml file: ``` <Switch android:layout_width="100dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="7dp" android:background="@drawable/offbuttonbg" android:textAppearance="@style/SwitchTextAppearance" android:thumb="@drawable/switchselector" /> ```

Original source