I want to design a button like that (it's a kind of toggle button with on and off); any suggestion or ready library or view to use it directly?
Asked
Active
Viewed 162 times
0

Gabriele Mariotti
- 320,139
- 94
- 887
- 841

Younes Charfaoui
- 1,059
- 3
- 10
- 20
-
1You can subclass MaterialButton, which supports checked states, and override the `toggle` function to show and hide the icon based on `isChecked`. Use a state list drawable for the button tint and text color that has different colors for the checked states. – Tenfour04 Jan 20 '21 at 14:52
1 Answers
1
You can use a Chip
.
Something like:
<com.google.android.material.chip.Chip
android:id="@+id/some_chip"
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Text 1" />

Gabriele Mariotti
- 320,139
- 94
- 887
- 841