我想在android中创建芯片,如下所示:
是否可以使用android studio这样做?如果是这样,我该如何使用XML?
尝试创建此CheckBox,但想知道如何添加主题,如上面的屏幕截图:
<CheckBox android:id="@+id/checkBox" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginTop="40dp"
android:text="Gold" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.113"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.008" />
您引用的视图组件称为chips。通过使用材料设计库,您可以使用像这样的芯片:
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>
来源:https://material.io/develop/android/components/chip/
为了使用材料设计库,您需要:
implementation 'com.google.android.material:material:1.0.0'
Theme.MaterialComponents.DayNight
查看完整的入门指南here。>>