Подтвердить что ты не робот

Приложение для Android-чипа для Android. Невозможно надуть xml

Компонент Tried Chip из обеих библиотек поддержки
com.google.android.support:design:28.0.0-rc01 и материал
com.google.android.material:material:1.0.0-rc01

Трассировки стека

android.view.InflateException: Binary XML file line #72: Binary XML file 
      line #72: 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)'

раскладка

<com.google.android.material.chip.Chip
    android:id="@+id/chip"
    style="style/Widget.MaterialComponents.Chip.Entry"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/account"
    app:closeIconEnabled="true" />'
4b9b3361

Ответ 1

Обновите тему своего приложения, чтобы унаследовать одну из следующих тем:

Theme.MaterialComponents
Theme.MaterialComponents.NoActionBar
Theme.MaterialComponents.Light
Theme.MaterialComponents.Light.NoActionBar
Theme.MaterialComponents.Light.DarkActionBar

Например:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

Примечание. Использование темы "Компоненты материала" позволяет настраивать вид

Источник: https://www.material.io/develop/android/docs/getting-started/

Ответ 2

Добавьте к существующей теме приложения следующие новые атрибуты темы:

<style name="Theme.MyApp" parent="Theme.AppCompat">

    <!-- Original AppCompat attributes. -->
    <item name="colorPrimary">@color/my_app_primary_color</item>
    <item name="colorPrimaryDark">@color/my_app_primary_dark_color</item>
    <item name="colorAccent">@color/my_app_accent_color</item>

    <!-- New MaterialComponents attributes. -->
    <item name="colorSecondary">?attr/colorPrimary</item>
    <item name="scrimBackground">@color/mtrl_scrim_color</item>
    <item name="textAppearanceHeadline1">@style/TextAppearance.MaterialComponents.Headline1</item>
    <item name="textAppearanceHeadline2">@style/TextAppearance.MaterialComponents.Headline2</item>
    <item name="textAppearanceHeadline3">@style/TextAppearance.MaterialComponents.Headline3</item>
    <item name="textAppearanceHeadline4">@style/TextAppearance.MaterialComponents.Headline4</item>
    <item name="textAppearanceHeadline5">@style/TextAppearance.MaterialComponents.Headline5</item>
    <item name="textAppearanceHeadline6">@style/TextAppearance.MaterialComponents.Headline6</item>
    <item name="textAppearanceSubtitle1">@style/TextAppearance.MaterialComponents.Subtitle1</item>
    <item name="textAppearanceSubtitle2">@style/TextAppearance.MaterialComponents.Subtitle2</item>
    <item name="textAppearanceBody1">@style/TextAppearance.MaterialComponents.Body1</item>
    <item name="textAppearanceBody2">@style/TextAppearance.MaterialComponents.Body2</item>
    <item name="textAppearanceCaption">@style/TextAppearance.MaterialComponents.Caption</item>
    <item name="textAppearanceButton">@style/TextAppearance.MaterialComponents.Button</item>
    <item name="textAppearanceOverline">@style/TextAppearance.MaterialComponents.Overline</item>

</style>

Источник: https://material.io/develop/android/docs/getting-started/
Спасибо @Paranoid42

Ответ 3

Наконец, было получено решение о том, как создавать чипы динамически с использованием новых материальных чипов

Google не предоставил никакой документации для компоновки chipInput или как сделать адрес gmail, такой как макет. Использование ChipDrawable не даст операции удаления на опцию чипа, поскольку не может вызвать setOnCloseIconClickListener. Я смог сделать это с помощью HorizontalScrollView, ChipGroup и EditText

Вот пример моего кода:

MaterialChipsInputDemo

Ответ 4

Вы можете добавить атрибут @style/Theme.MaterialComponents.Light style в макет xml следующим образом:

<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="chip"
android:theme="@style/Theme.MaterialComponents.Light"/>

Ответ 5

Добавьте компонент chip который включен в библиотеку поддержки Android.

реализация 'com.android.support:design:28.0.0-rc01'

<android.support.design.chip.Chip
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 

    />

Дополнительные ссылки

отредактированный

Добавьте это в свой файл gradle

 implementation group: 'com.google.android.material', name: 'material', version: '1.0.0-alpha1'

XML

    <com.google.android.material.chip.Chip
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:chipText="MATERIAL CHIP" />

ВЫВОД

enter image description here