Android material chips

17,465

Solution 1

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" />

enter image description here

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: If true, the chip can be toggled. If false, the chip acts like a button
  • app:chipIcon: Used to display an icon within the chip
  • app:closeIcon: Used to display a close icon within the chip

You can find the official documentation here.

Solution 2

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.

Solution 3

there is also a new library for material chips!

Share:
17,465

Related videos on Youtube

Sandra
Author by

Sandra

Updated on June 04, 2022

Comments

  • Sandra
    Sandra almost 2 years

    I want to implement an autocomplete edittext with chips in my application and I want to do it in a way that it's done here: material design chips. First I would like to ask if there is some kind of widget (maybe as part of the new support library) or a solution that I can use for easy implementation. (I know that this question has been asked before but I just want to know if something changed in the meantime). Also I found this library, but I don't know how can I use it (and can I use it) for autocompletion of my sets of data... Has anyone worked with this library before and can share their experience?

    Any help would be appreciated!

  • Sandra
    Sandra about 8 years
    Thank you very much! I'll check it out as soon as possible.
  • Sandra
    Sandra almost 6 years
    I found this myself, this is exactly what was needed a long time ago. Great that we are getting it finally. Thanks!
  • Darush
    Darush almost 6 years
    Why is app:checkable not working? I get the "error: attribute checkable not found."
  • Darush
    Darush almost 6 years
    @GabrieleMariotti I used android:checkable instead of app:checkable and it worked. Any ideas would be very much appreciated.