1

我的应用程序在尝试为com.google.android.material.chip.Chip课程充气时崩溃。

我使用的依赖是implementation 'com.google.android.material:material:1.0.0'

这是我的 XML 代码

 <com.google.android.material.chip.Chip
        android:id="@+id/chipActive"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:chipCornerRadius="5dp"
        android:backgroundTint="@color/primaryColor"
        android:textColor="@color/primaryTextColor"
        android:textAlignment="center"
        android:fontFamily="@font/roboto_regular"
        android:layout_marginStart="10dp"
        android:text="Active"/>

我得到的错误是

 android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class com.google.android.material.chip.Chip
    at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429)

我在另一个线程上发现了一个与我类似的问题,但那里没有对我有帮助的解决方案。如果有人对如何解决此问题有任何建议,请帮助我:D

4

3 回答 3

4

发布此问题后,我找到了解决方案。我将依赖项更新为implementation 'com.google.android.material:material:1.1.0-alpha02',现在它工作正常。

于 2019-01-09T08:59:20.543 回答
2

使用主题<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

于 2019-03-02T10:07:34.250 回答
1

将此代码放入芯片中

android:theme="@style/Theme.MaterialComponents.Light"

于 2021-08-26T11:59:36.693 回答