The switch displays a lot of drawings for the thumb and track of a certain size

I use the Switch view, and I use my drawing resources for the thumb and track. So far, in order not to display the text on the thumb, but to have it with a certain width, I do this: for example, I want the thumb to be 40 dp, then I set thumbTextPadding to 20dp. Is there a better way to do this? I have one more problem. I need the width of the track to be exactly 2 * the width of the thumb, but I noticed that the switch sets its width a little more, and for me this is important. Can anyone help me with this? Thanks.

+4
source share
1 answer

To solve this problem, set the minimum width for the switch:

android:switchMinWidth="40dp" 

I have not yet found a way to set thumb width without using thumbTextPadding.

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1442205/


All Articles