Varun Verma
Varun Verma

Reputation: 542

Android Switch widget textOn and textOff not working as expected

I have a UI where I have added a Switch widget (introduced in API 14). The XML looks like this:

<Switch
    android:id="@+id/togglebutton"
    android:layout_margin="10dp"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textOff="No"
    android:textOn="Yes" />

You can see that I have specified textOn and textOff. So I expect this text on the switch widget.

However, what I get is: enter image description here enter image description here

Have checked everything in debugging ... still don't understand why my custom text does not appear !!

Also, the custom text appears on the Galaxy S2 (Android 4.0.4) but does not appear on 10" Galaxy Tab also on Android 4.0.4 !!

Please help.

Upvotes: 2

Views: 2847

Answers (1)

Varun Verma
Varun Verma

Reputation: 542

I solved it ...

The issue was that for the Galaxy tab the default theme is something else ... its not Holo.Light for example !

Once I force the theme (in my app) to inherit from the Holo.Light I got the desired result ...

Upvotes: 5

Related Questions