简体   繁体   English

android开关样式不适用于KitKat(4.4.2)

[英]android switch style is not applied on KitKat (4.4.2)

I applied some custom styles on items. 我在项目上应用了一些自定义样式。 When I am testing my application on different devices, I realized that all styles are applied properly except Switch style on Kitkat(4.4.2). 当我在不同设备上测试应用程序时,我意识到除了Kitkat(4.4.2)上的Switch样式外,所有样式都可以正确应用。 Is there a compatibility issue or should I use a different approach. 是否存在兼容性问题,或者我应该使用其他方法。 I spent some time searching a similar problem, however could not find. 我花了一些时间搜索类似的问题,但是找不到。 There is no problem with 4.2 and 4.3 devices but on 4.4 only switch style is not applied. 4.2和4.3设备没有问题,但在4.4上仅不应用开关样式。

This is my style: 这是我的风格:

<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>

and this is the switch 这是开关

  <Switch
     android:id="@+id/filter_switch"
     style="@style/switchStyle"
     android:layout_marginTop="20dp"
     android:checked="true"
     android:text=""
     android:textOff="On"
     android:textOn="Off" />

Is there a better way to customize switch? 有更好的自定义开关方法吗? Is this problem really related with os version? 这个问题真的和os版本有关吗?

Thank you. 谢谢。

I thought that it was about the os version but I realized that somehow I forgot to add the related background image for specific screen size. 我以为这是关于os版本的,但是我意识到以某种方式忘记为特定的屏幕尺寸添加相关的背景图片。 Since I forgot on only one screen size, style applied for all of other devices. 由于我只忘记一种屏幕尺寸,因此样式适用于所有其他设备。 But I wonder why it did'nt show any error or warnings. 但是我不知道为什么它没有显示任何错误或警告。 The related screen opened without no error or warnings. 相关屏幕打开,没有错误或警告。 It allocated the layout place but did not show the switch. 它分配了布局位置,但未显示开关。

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

相关问题 AlarmManager在Android版本4.4.2 KitKat中触发两次 - AlarmManager fires twice in Android Version 4.4.2 KitKat Android Kitkat 4.4.2:自适应播放对SurfaceFlinger的影响 - Android Kitkat 4.4.2: Adaptive Playback impact on SurfaceFlinger Android Kitkat 4.4.2 ImageView setBackgroundResource无法正常工作? - Android Kitkat 4.4.2 ImageView setBackgroundResource not working? Android DigitalClock在Kitkat 4.4.2中不显示秒 - Android DigitalClock not displaying seconds in Kitkat 4.4.2 Android 4.4.2 Kitkat无法使用HttpURLConnection发送请求 - Android 4.4.2 Kitkat can not send a request with HttpURLConnection 在webview android kitkat 4.4.2上“选择要上传的文件” - “choose file to upload” on webview android kitkat 4.4.2 在Android 4.4.2 KitKat中使用moveTaskToBack覆盖后退按钮 - Override back button with moveTaskToBack in Android 4.4.2 KitKat Android应用程序仅在运行Android 4.4.2的Google nexus 7中崩溃-Kitkat - Android app crashing only in google nexus 7 running android 4.4.2 - kitkat 如何使用Android版本4.4.2(KITKAT)检测文件夹是否可写 - Howto detect if a folder is writable with Android Version 4.4.2 ( KITKAT ) 系统生成的缩略图检索在自定义Android KitKat 4.4.2中无法正常工作 - System generated thumbnail retrieval not working properly in custom Android KitKat 4.4.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM