Different attributes for Spinner widget
XML attributes | Description |
---|---|
android:id | Used to specify the id of the view. |
android:textAlignment | Used to the text alignment in the dropdown list. |
android:background | Used to set the background of the view. |
android:padding | Used to set the padding of the view. |
android:visibility | Used to set the visibility of the view. |
android:gravity | Used to specify the gravity of the view like center, top, bottom etc |
Spinner in Kotlin
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.
Contact Us