Drop-Down Menu in Android using Jetpack Compose Last Updated : 18 May, 2025 Comments Improve Suggest changes Like Article Like Report In Android, a TextField is used to take text-based input from the user to perform a particular task. This text can be general text or be specific to characters, numbers, etc. However, this is not the only purpose of implementing a TextField. A TextField can also be converted into a drop-down menu displaying options to be selected by the user. So in this article, we will show you how you could create a Drop-Down Menu in Android using Jetpack Compose.Step by Step ImplementationStep 1: Create a New Project in Android StudioTo create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.Step 2: Working with the MainActivity.kt fileGo to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.MainActivity.kt: Kotlin package com.geeksforgeeks.demo import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.KeyboardArrowDown import androidx.compose.material.icons.filled.KeyboardArrowUp import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Size import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.toSize class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MaterialTheme { // call composable DropdownDemo() } } } } // Creating a composable to display a drop down menu @Composable fun DropdownDemo() { // Declaring a boolean value to store // the expanded state of the Text Field var mExpanded by remember { mutableStateOf(false) } // Create a list of cities val mCities = listOf("Delhi", "Mumbai", "Chennai", "Kolkata", "Hyderabad", "Bengaluru", "Pune") // Create a string value to store the selected city var mSelectedText by remember { mutableStateOf("") } var mTextFieldSize by remember { mutableStateOf(Size.Zero)} // Up Icon when expanded and down icon when collapsed val icon = if (mExpanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown Column(Modifier.padding(20.dp)) { // Create an Outlined Text Field // with icon and not expanded OutlinedTextField( value = mSelectedText, onValueChange = { mSelectedText = it }, modifier = Modifier .fillMaxWidth() .onGloballyPositioned { coordinates -> // This value is used to assign to // the DropDown the same width mTextFieldSize = coordinates.size.toSize() }, label = {Text("Label")}, trailingIcon = { Icon(icon,"contentDescription", Modifier.clickable { mExpanded = !mExpanded }) } ) // Create a drop-down menu with list of cities, // when clicked, set the Text Field text as the city selected DropdownMenu( expanded = mExpanded, onDismissRequest = { mExpanded = false }, modifier = Modifier .width(with(LocalDensity.current){mTextFieldSize.width.toDp()}) ) { mCities.forEach { label -> DropdownMenuItem( text = { Text(text = label) }, onClick = { mSelectedText = label mExpanded = false } ) } } } } Output: Comment More infoAdvertise with us Next Article Drop-Down Menu in Android using Jetpack Compose A aashaypawar Follow Improve Article Tags : Kotlin Android Android-Jetpack Similar Reads Deep Links in Android using Jetpack Compose A deep link is a URL that is used to direct users to a specific page or specific activity within the application. We can also pass data to our application with the help of these deep links. In this article, we will take a look at How to implement Deep Links in Android using Jetpack Compose. Step by 7 min read Text in Android using Jetpack Compose Jetpack Compose is a new toolkit provided by Google. This is useful for designing beautiful UI designs. Android Text is a simple view in Android which is used to display text inside our App. In this article, we will take a look at the implementation of Text in Android using Jetpack Compose. Importan 5 min read Date Picker in Android using Jetpack Compose In Android, a Date Picker is a widget used to select a date from the calendar. When a Date Picker is implemented in an application, the user can select a year, a month, and a day, combining to form date from a calendar-like-looking box. This data is generally needed and collected in applications tha 2 min read Contact Picker in Android using Jetpack Compose Many applications require a functionality where users can pick a specific contact from their contact list and display that contact within the android application to perform some action on that contact such as sending an SMS or making a call. In this article, we will take a look at How to create a co 6 min read UPI Payment Integration in Android using Jetpack Compose If you are selling any product or providing any service in your android application, then you should have integrated a feature in your android application where you can allow users to make payments through your application. In this article, we will take a look at the implementation of payment gatewa 4 min read Like