Android Toggle Button - Material Design

Viewed 23949

How do I implement the Toggle Buttons as specified in Material Design guidelines here?

Is it available out of the box from Android Design Support Library or is there any third party library available?

6 Answers

With the Material Components Library you can use the MaterialButtonToggleGroup.

Something like:

 <com.google.android.material.button.MaterialButtonToggleGroup
        android:id="@+id/toggleButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="A"
            style="?attr/materialButtonOutlinedStyle"
            />
        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="B"
            style="?attr/materialButtonOutlinedStyle"
            />
        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="C"
            style="?attr/materialButtonOutlinedStyle"
            />
    </com.google.android.material.button.MaterialButtonToggleGroup>

enter image description here

Related