Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide default text for android switch Button

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" />
like image 630
Madhu Avatar asked Feb 18 '15 14:02

Madhu


1 Answers

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" />
like image 128
Fahim Avatar answered Nov 03 '22 07:11

Fahim