Exposed Drop-Down Menu in Android

Emine İNAN
Nerd For Tech
Published in
2 min readAug 8, 2021

In this article, we will explore the Exposed Drop-Down Menu in Android. With the help of the Exposed Drop-Down Menu, we can quickly and easily select an item from a list.

​Let’s learn the use of Exposed Drop-Down Menu with a simple app that asks the user how they are feeling today.

Step 1

Create a new project in Android Studio.

Step 2

Open the activity_main.xml. Add a TextView to write the question text.

TextView

Then add a TextInputLayout that contains an AutoCompleteTextView to use Exposed Drop-Down Menu.

TextInputLayout and AutoCompleteTextView

You can choose the style you want for Exposed Drop-Down Menu with the style property in TextInputLayout.

Style

You can put a title in your Exposed Drop-Down Menu with hint property in TextInputLayout.

Hint

You can put an icon in your Exposed Drop-Down Menu with the startIconDrawable property in TextInputLayout.

Icon

Step 3

Go to strings.xml and add string array items there.

strings.xml

Step 4

Create a new layout file called dropdown_item.xml and add a TextView that will represent a single item of the Exposed Drop-Down Menu.

dropdown_item.xml

Step 5

Open the MainActivity.kt and create a variable named feelings and get a reference to the string array. Then create an array adapter and pass the context, dropdown layout, and array. Finally, set adapter to the autoCompleteTextView to the arrayAdapter.

MainActivity.kt

Step 6

Run your application.

Output

--

--

Emine İNAN
Nerd For Tech

Android Developer by day, Android Developer by night. @Huawei