Search code examples
androidkotlinmaterial-designandroid-textinputlayout

Android TextInputLayout Exposed Dropdown Menu


Recently, android introduced a new Exposed dropdown menu for Text Input Layout.

I am trying to add it in my XML but cannot find it.

I am using the latest material design version 1.2.0-alpha05.

Also my style is using the Material components as shown below:

<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>

However, i still cannot find the new Exposed Drop Down menu as per Material.io.

Can someone please guide me how to get this in my app.


Solution

  • Use style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu" in your TextInputLayout like this:

    <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>