【问题标题】:Android TextInputLayout Exposed Dropdown MenuAndroid TextInputLayout 暴露的下拉菜单
【发布时间】:2020-07-22 20:49:45
【问题描述】:

最近,android 为 Text Input Layout 引入了一个新的 Exposed 下拉菜单。

我正在尝试将它添加到我的 XML 中,但找不到它。

我正在使用最新的材料设计版本 1.2.0-alpha05。

我的风格也是使用 Material 组件,如下所示:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="actionOverflowButtonStyle">@style/actionButtonOverflow</item>
</style>

但是,我仍然无法根据 Material.io 找到新的 Exposed Drop Down 菜单。

有人可以指导我如何在我的应用中获取它。

【问题讨论】:

    标签: android kotlin material-design android-textinputlayout


    【解决方案1】:

    在您的TextInputLayout 中使用style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu",如下所示:

    <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">
    
      <AutoCompleteTextView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/>
    
    </com.google.android.material.textfield.TextInputLayout>
    

    【讨论】:

    • 我们将如何检索选定的值
    猜你喜欢
    • 2021-05-03
    • 2020-02-22
    • 2020-09-03
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 2019-10-31
    • 1970-01-01
    • 2020-10-30
    相关资源
    最近更新 更多