
Ensure that the id you will use is the same as what you define in the layout file. Now, you can pass the new layout to the ArrayAdapter. Set the id to text1, for example, then, set the textSize to your liking. Set the root element to TextView and you are good to go. Go to File> New, then Layout resource file. No need of setting up your res file because you can just call your Spinner layout file to show the items on your Spinner.Īlternatively, you can also do a custom layout by creating an XML file in the res/layout folder. SP means scalable pixels or scale-independent pixels. For text sizes, it’s recommended to use sp. If you have noticed, you can find px, dp, sp, etc. There are different units when it comes to Android development. You can define the textSize XML attribute to the size of the text you want to be followed by ‘ sp.’ You can refer to the following code to learn more. In this layout file, you can use the TextView user interface control. Try making a custom XML file for your Spinner item. Through this, some commands for the data value, including text size and style can be implemented.

It’ll only be defined once the ArrayAdapter is created when the data is linked to the Spinner. xml file) doesn’t define the View that the value being displayed uses. Apps with a dropdown menu have tendencies to implement Android Spinner in the backend.

You might not aware of that, but perhaps, some of your favorite apps used Android Spinner. It’s a dropdown menu with multiple values and the end-user can select only one value. Android Spinner is a great tool to display several options to users from which he/she can choose one.
