[英]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.