[英]android switch style is not applied on KitKat (4.4.2)
我在项目上应用了一些自定义样式。 当我在不同设备上测试应用程序时,我意识到除了Kitkat(4.4.2)上的Switch样式外,所有样式都可以正确应用。 是否存在兼容性问题,或者我应该使用其他方法。 我花了一些时间搜索类似的问题,但是找不到。 4.2和4.3设备没有问题,但在4.4上仅不应用开关样式。
这是我的风格:
<style name="switchStyle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">0dp</item>
<item name="android:layout_marginBottom">0dp</item>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginRight">20dp</item>
<item name="android:thumb">@drawable/ab_bottom_solid_btom</item>
<item name="android:track">@drawable/switch_bg</item>
<item name="android:thumbTextPadding">30dp</item>
<item name="android:switchPadding">30dp</item>
</style>
这是开关
<Switch
android:id="@+id/filter_switch"
style="@style/switchStyle"
android:layout_marginTop="20dp"
android:checked="true"
android:text=""
android:textOff="On"
android:textOn="Off" />
有更好的自定义开关方法吗? 这个问题真的和os版本有关吗?
谢谢。
我以为这是关于os版本的,但是我意识到以某种方式忘记为特定的屏幕尺寸添加相关的背景图片。 由于我只忘记一种屏幕尺寸,因此样式适用于所有其他设备。 但是我不知道为什么它没有显示任何错误或警告。 相关屏幕打开,没有错误或警告。 它分配了布局位置,但未显示开关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.