質問

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

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?

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. 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帰属
所属していません StackOverflow
scroll top