Skip to content Skip to sidebar Skip to footer

How To Create This Toggle Button?

How can I create a toggle button that looks like this? Currently I have the below:

Solution 1:

try this,

build.gradle

dependencies {
compile'info.hoang8f:android-segmented:1.0.6'

}

@style/RadioButton

    <attr name="sc_corner_radius"format="dimension" />
<attr name="sc_border_width"format="dimension" />
<attr name="sc_tint_color"format="color" />
<attr name="sc_checked_text_color"format="color" />

code

     <info.hoang8f.android.segmented.SegmentedGroup
        xmlns:segmentedgroup="http://schemas.android.com/apk/res-auto"
        android:id="@+id/segmented2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:orientation="horizontal"
        segmentedgroup:sc_border_width="2dp"
        segmentedgroup:sc_corner_radius="10dp">

        <RadioButton
            android:id="@+id/button21"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="One"
            style="@style/RadioButton" />

        <RadioButton
            android:id="@+id/button22"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Two"
            style="@style/RadioButton" />

        <RadioButton
            android:id="@+id/button24"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Two"
            style="@style/RadioButton" />
    </info.hoang8f.android.segmented.SegmentedGroup>

Post a Comment for "How To Create This Toggle Button?"