V
V
Valera Figol2017-03-10 16:49:40
Android
Valera Figol, 2017-03-10 16:49:40

How to make a switch on android?

Hello everyone, I have a switch instead of a standard slider that writes the text "On / Off", how to make it a slider?

<GridLayout
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="42.0dp"
        android:id="@+id/gridLayout_for_switch"
        android:background="@color/white"
        android:columnCount="2"
        android:rowCount="2"
        android:layout_marginTop="15.0dp">
        <TextView
            android:text="PayPal"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView2"
            android:textColor="@color/black"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_marginLeft="10dp"
            android:textSize="15sp" />
        <Switch
            android:id="@+id/paypal_switch"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:layout_width="90dp"
            android:layout_marginRight="5.0dp" />
    </GridLayout>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Voronov, 2017-03-10
@Kamrit

This is the standard Switch. You can make it a slider by customizing your style .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question