gpt4 book ai didi

android - 无法解析 Widget.MaterialComponents.TextInputLayout.*.ExposedDropdownMenu

转载 作者:搜寻专家 更新时间:2023-11-01 09:20:19 28 4
gpt4 key购买 nike

我试图创建一个 AutoCompleteTextView,它被 TextInputLayout 包围。根据documentation ,我应该使用这种风格:

Widget.MaterialComponents.TextInputLayout.*.ExposedDropdownMenu 

但是我无法解析这个样式。 Android Studio 说我只能使用:

@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense
@style/Widget.MaterialComponents.TextInputLayout.FilledBox
@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense
@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox

我的项目使用

implementation 'com.android.support:design:28.0.0'

最终结果应该是这样的:

<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_text">

<AutoCompleteTextView
android:id="@+id/filled_exposed_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</com.google.android.material.textfield.TextInputLayout>

最佳答案

我在 Android Material Components 的 Github 问题中提出了这个问题。

基于 this response ,公共(public)文档不是基于当前的稳定版本,而是基于最新的 alpha(或 beta)版本。无法从 material.io 上的文档中判断哪些组件处于库的稳定版、alpha 版或 beta 版中。

澄清后,这个问题的解决方案是按照@jeel-vankhede 的建议将您的支持设计库升级到:

implementation 'com.google.android.material:material:1.1.0-alpha07'

相关提示,以防您还使用 ViewModels(lib v.2.0.0):

升级到 Material design 库的 1.1.0-alpha 会自动将 androidx.lifecycle 库更新到 2.1.0+。此更新与 2.0.0 相比有重大变化,可能会破坏您的 View 模型代码。此更改仅在应用的缩小版本中观察到。

关于android - 无法解析 Widget.MaterialComponents.TextInputLayout.*.ExposedDropdownMenu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56557435/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com