P
P
Petr Petrovich2018-12-30 00:35:49
Android
Petr Petrovich, 2018-12-30 00:35:49

How to lengthen Switch?

In all Google guidelines, the Switch widget (aka SwitchCompat) has a long track.
5c27e88ea76fc935307486.png
However, if you use this widget from the support library, the track will be short:
5c27e894e5c27716872959.png
What's the easiest way to make it longer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chris, 2018-12-30
@tv_dakota

Add these lines to the tag in the XML file.

android:scaleX="2"
android:scaleY="2"

You can change the scale value according to your needs. A value of 2 doubles it, similarly a value of 0.5 halves it.
Example:
<Switch
            android:id="@+id/switchOnOff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleX="2"
            android:scaleY="2"/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question