如何使用Android支持库中的Chips组件? [英] How to use Chips component from android support library?
问题描述
我已阅读官方网站上的文档.但是,根据文档,我无法在我的项目中实现Chip. Android Studio无法找到和导入 Chip 类以及 Chip 视图.
I have read the documentation on the official website. But I was unable to implement Chip in my project following the documentation. Android Studio can't find and import Chip class as well as Chip view.
我还注意到,在 Google Developer网站上,没有关于Chip类的参考
I have also noticed that on Google Developer site there is no reference for Chip class.
还有一些类似的问题.但是所有答案都指向使用第三方库.但是我正在尝试使用android支持库中的Chips组件.
There are some similar questions. But all answers point to use a third-party library. But I am trying to use Chips component from android support library.
推荐答案
该功能包含在支持库版本28.0.0-alpha1中. 要使用该功能:
The feature is included in support library version 28.0.0-alpha1. To use the feature:
在应用gradle文件中:
In app gradle file:
android {
compileSdkVersion 'android-P'
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
// OR
implementation 'com.android.support:design-chip:28.0.0-alpha1'
}
在布局文件中:
<android.support.design.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipIcon="@drawable/ic_arrow_drop_down_black_24dp"
app:chipText="hello"/>
指南: https://material.io/guidelines/components/chips.html
这篇关于如何使用Android支持库中的Chips组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!