Android material chips
The new Material Components for Android contains the component Chip
.
You can add the chip to your layout file with:
<com.google.android.material.chip.Chip
android:id="@+id/some_chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is a chip" />
With the classic Design Support Library 28.0.0 you can use the package:
<android.support.design.chip.Chip
../>
You can customize the component using these attributes:
android:checkable
: Iftrue
, the chip can be toggled. Iffalse
, the chip acts like a buttonapp:chipIcon
: Used to display an icon within the chipapp:closeIcon
: Used to display a close icon within the chip
You can find the official documentation here.
I actually ended up using this library. The autocomplete view and chips that this library provides are not "materially" styled, but you can do it yourself with no great effort. After great research I realized that this library gives you the most easy way of implementing your own sets of data into the logic. All the other libraries were customized for using Android contact or emails, and it was not so trivial to change the code and query your own sets of data. So if someone wants to implement chips, but with custom data querying I'd say this is the right way to go.