Vance
Vance

Reputation: 95

android.support.design.chip.Chip

I'm face to a problem with chip component on android. I try to implemente a chip like this:

    <android.support.design.chip.Chip
        android:id="@+id/tags"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello world"/>

But when I launch my app I have this error:

android.view.InflateException: Binary XML file line #59: Binary XML file line #59: Error inflating class android.support.design.chip.Chip

Caused by: android.view.InflateException: Binary XML file line #59: Error inflating class android.support.design.chip.Chip

Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).

My style is already an AppCompact.

Upvotes: 2

Views: 1071

Answers (1)

Jeel Vankhede
Jeel Vankhede

Reputation: 12118

You need to use app theme to Theme.MaterialComponents.Light.Bridge inspite of AppCompat if you want to use android.support.design.chip.Chip.

Reason:

Chip component relies on new MaterialComponents theme, so is why the crash occurs. Bridge theme here are treated as AppCompat but provides new MaterialComponents theme when needed.

Upvotes: 4

Related Questions