简体   繁体   English

Android Switch小部件textOn和textOff无法正常工作

[英]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). 我有一个UI,在其中添加了Switch小部件(在API 14中引入)。 The XML looks like this: XML如下所示:

<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. 您可以看到我已经指定了textOn和textOff。 So I expect this text on the switch widget. 因此,我希望此文本在switch小部件上。

However, what I get is: 但是,我得到的是: 在此处输入图片说明在此处输入图片说明

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 !! 另外,自定义文本显示在Galaxy S2(Android 4.0.4)上,但在Android 4.0.4上也未显示在10“ Galaxy Tab上!

Please help. 请帮忙。

I solved it ... 我解决了...

The issue was that for the Galaxy tab the default theme is something else ... its not Holo.Light for example ! 问题是,对于“ Galaxy”选项卡,默认主题是其他主题……例如,它不是Holo.Light!

Once I force the theme (in my app) to inherit from the Holo.Light I got the desired result ... 强制主题(在我的应用程序中)从Holo.Light继承后,我得到了所需的结果...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM