Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android material chips

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!

like image 383
Sandra Avatar asked Jan 20 '15 12:01

Sandra


People also ask

What are Android chips?

Chips are compact elements that represent an attribute, text, entity, or action. They allow users to enter information, select a choice, filter content, or trigger an action.

What are chips in material design?

Chips are compact elements that represent an input, attribute, or action. All chips now share a boxier shape with rounded corners, updated color mappings, and dynamic color compatibility. Action chips are now further defined as assist or suggestion chips.

How do you use the chip group on Android?

A ChipGroup is used to hold multiple Chip s. By default, the chips are reflowed across multiple lines. Set the app:singleLine attribute to constrain the chips to a single horizontal line. If you do so, you'll usually want to wrap this ChipGroup in a HorizontalScrollView .


1 Answers

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.

like image 88
Gabriele Mariotti Avatar answered Oct 05 '22 22:10

Gabriele Mariotti