Draw thumb and tracker from toggle button to left of text

The default result when setting the text on the toggle button is the big / road sign on the right.

+-------------+----------+
|             |          |
|  Lorem Ispu | on / off |
|             |          |
+-------------+----------+

      

What you need to know if there is any way to make the bump / sticker placed on the left side of the text without having to write your own widget:

+-----------+-------------+
|           |             |
|  on / off | Lorem Ipsum |
|           |             |
+-----------+-------------+

      

Thank:)

+3


source to share


2 answers


The only way I have found is to turn Switch and TextView on and off in LinearLayout:

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <android.support.v7.widget.SwitchCompat
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="true"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Your text:"/>
</LinearLayout>

      



Hope this helps. The idea was the same as mentioned here: How to show android checkbox on the right side? I just changed the order.

+2


source


To set the default for the switch, you must define this code in the xml



android:checked="true" 

      

-2


source







All Articles