Analizer
Analizer

Reputation: 1644

Providing track drawable to switch messes up appearance

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?

Upvotes: 1

Views: 105

Answers (1)

Sanjeet A
Sanjeet A

Reputation: 5227

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.

Upvotes: 2

Related Questions