1

I'm trying to set a custom drawable as track to a switch, but when I do that, it makes the thumb fill the track instead of overflowing it.

Switch without custom drawable:

enter image description here

Switch with the custom drawable applied:

enter image description here

Expected:

enter image description here

Style of the switch:

<style name="switch_style">
    <item name="android:track">@drawable/switch_track_selector</item>
    <item name="android:thumb">@drawable/switch_thumb_selector</item>
</style>

Any idea?

Analizer
  • 1,594
  • 16
  • 30

1 Answers1

2

You can achieve this using the SwitchComapt instead of switch and changing the theme. You can have a look on this question.

Edit

if you are using the support libraries then you don't need any specific them even, Your SwichComapt will be automatically as per your current theme.

Community
  • 1
  • 1
Sanjeet A
  • 5,171
  • 3
  • 23
  • 40
  • bounty points well spent (altough I need to wait a few hours for that), thanks a lot for your help, it finally works! :) – Analizer Nov 16 '15 at 08:49