1

I am now trying to use chips UI, so I started looking for the APIs. But it seems like there are no such APIs for the chips in Android basically provided by Google even though there is an introduction to the UI components of material design chips on the website (https://www.google.com/design/spec/components/chips.html).

So instead it seems like I have to use third party libraries like https://github.com/klinker41/android-chips. But before that I just want to find out if this will be the only option to use chips.

Psypher
  • 10,717
  • 12
  • 59
  • 83
MarshallLee
  • 1,290
  • 4
  • 23
  • 42

2 Answers2

2

But it seems like there are no such APIs for the chips in Android basically provided by Google even though there is an introduction to the UI components of material design chips on the website (https://www.google.com/design/spec/components/chips.html).

Lots of what is described in the Material Design specification is not available directly from Google for Android.

I just want to find out if this will be the only option to use chips

It certainly is your only option today, besides creating a chips-style UI yourself from scratch.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Alright.. so I have no choice but to include the third party library in the build.gradle file unless I am willing to make my own UI APIs then. – MarshallLee Nov 30 '15 at 23:25
  • 1
    @newbieprogrammer: Correct, or do not use the chips UI pattern. Though note that there are a few chips implementations floating around. The original one for Android was written by Roman Nurik, a Google developer advocate. – CommonsWare Nov 30 '15 at 23:27
  • @CommonsWare, that's a good information to know. Any idea when the Android version of chip eidget is gonna be available in support library ? At the moment only one 3rd party library supports Material Chip widgets but supports only Contacts and Email data, does not support custom data. I need an adapter for my custom data. Changing this library for that to work is, I think, a big effort. Your guidance on this will be of greatly helpful. – cgr Dec 06 '15 at 12:50
  • "Any idea when the Android version of chip eidget is gonna be available in support library?" -- some time between tomorrow and never. Google does not announce future plans like that much. – CommonsWare Dec 06 '15 at 13:02
  • Check out this answer. No need to use 3rd party libs. http://stackoverflow.com/a/41776777/2254969 – Ankit Aggarwal Jan 21 '17 at 07:26
0

Posting an updated answer since its part of google design library.

Chip is a rounded button that consists of a label, an optional chip icon, and an optional close icon. A chip can either be clicked or toggled if it is checkable. It extends the AppCompatCheckBox.

These are divided into 3 categories:

  1. Filter chip
  2. Choice chip
  3. Action chip

Now Chip is available as part of android design support library. You can now add a chip as below:

<com.google.android.material.chip.Chip
    style="@style/Widget.MaterialComponents.Chip.Action"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:chipIcon="@drawable/ic_action_24"
    app:chipText="@string/hello_world"/>

More details here in this link

Psypher
  • 10,717
  • 12
  • 59
  • 83