Android Switch Widget:设置android:track会导致拇指和曲目不显示

Android Switch Widget:设置android:track会导致拇指和曲目不显示,第1张

概述我无法自定义 Android Switch小部件的外观.我有自定义xml drawables,我想用于拇指(通常显示为On或Off的小按钮部分)和轨道(拇指滑过的背景).当我使用android:thumb设置拇指时,它工作正常.当我设置轨道时(无论是否设置了拇指),开关完全消失,我只剩下文字显示. 只需应用拇指,这是我的代码: <com.blahblahblah.blah.CustomSwitch 我无法自定义 Android Switch小部件的外观.我有自定义xml drawables,我想用于拇指(通常显示为On或Off的小按钮部分)和轨道(拇指滑过的背景).当我使用androID:thumb设置拇指时,它工作正常.当我设置轨道时(无论是否设置了拇指),开关完全消失,我只剩下文字显示.

只需应用拇指,这是我的代码:

<com.blahblahblah.blah.CustomSwitch    androID:ID="@+ID/switch_1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:textOff="Off"    androID:textOn="On"    androID:text="Something Awesome"    androID:textcolor="@androID:color/black"    androID:thumb="@drawable/custom_switch_thumb" />

以下是预览窗口中的内容:

并应用跟踪:

<com.blahblahblah.blah.CustomSwitch    androID:ID="@+ID/switch_1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:textOff="Off"    androID:textOn="On"    androID:text="Something Awesome"    androID:textcolor="@androID:color/black"    androID:track="@color/track_color" />

应用了轨道的预览窗口:

作为参考,我在OSX 10.7.5上使用AndroID Studio 0.2.3.

解决方法 我偶然发现了同样的问题,并在 HoloEverywhere issue tracker上找到了解决办法.你需要设置< size>您正在使用的可绘制XML形状.

不工作(小部件在那里,我可以与它进行交互,但我看不到它,它是隐藏的):

<shape xmlns:androID="http://schemas.androID.com/apk/res/androID"  androID:shape="rectangle">  <solID androID:color="@color/black_50" /></shape>

工作(不是添加的< size>):

<shape xmlns:androID="http://schemas.androID.com/apk/res/androID"  androID:shape="rectangle">  <solID androID:color="@color/black_50" />  <size androID:wIDth="56dp" androID:height="20dp" /></shape>
总结

以上是内存溢出为你收集整理的Android Switch Widget:设置android:track会导致拇指和曲目不显示全部内容,希望文章能够帮你解决Android Switch Widget:设置android:track会导致拇指和曲目不显示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1134748.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存