Android Spinner is a view similar to a dropdown list which is used to select one option from the list of options. It provides an easy way to select one item from the list of items and it shows a dropdown list of all values when we click on it. The default value of the android spinner will be the currently selected value and by using the Adapter we can easily bind the items to the spinner objects. Generally, we populate our Spinner control with a list of items by using an ArrayAdapter in our Kotlin file. First, we create a new project by following the below steps:
Click on File, then New => New Project.
After that include the Kotlin support and click on next.
Select the minimum SDK as per convenience and click the next button.
Then select the Empty activity => next => finish.
Different attributes for Spinner widget
Used to specify the id of the view.
Used to the text alignment in the dropdown list.
Used to set the background of the view.
Used to set the padding of the view.
Used to set the visibility of the view.
Used to specify the gravity of the view like center, top, bottom etc
Modify activity_main.xml file
In this file, we use the TextView and Spinner widgets and also set their attributes.