
This solution seems way cleaner, with no dirty hacks - just add popupWindow?.dismiss() when the header clicked. Thus… Not a lot of work was required to transition 8) That’s what we all love. Note that you can use the very same CountryAdapter but rename the getDropDownView() method to getView(), and get rid of existing getView().
Android studio listview font xml full#
We have full control of its UI! I chose ListView, could be anything else! All rendered by layout_country_dropdown.xml. So here we handle the dropdown view by ourselves. what you want user to enter in this edit text. hint: hint is an attribute used to set the hint i.e. EditText editText (EditText)findViewById(R.id.simpleEditText) tText('Username') //set the text in edit text. The magic of adding a header will be done in our CountryAdapter class:ĬountryAdapter.kt class CountryAdapter( context: Context ) : ArrayAdapter(context, 0, OperatedCountry.values()) Below is the example code in which we set the text in a text view programmatically means in java class. With property android:background we can add a blue outline when Spinner is in the selected state and with android:popupBackground the background of dropdown view - easy so far.
Android studio listview font xml android#
Thanks to we can see in Android Studio Designer how the Spinner will look like and adjust paddings/margins properly :) In this way, we’ve just built a Spinner widget on our UI. OK, so let’s begin with implementing the layout: Is it possible to implement using Spinner Widget? Let’s see. So the design for selection was not looking like a default Android Spinner as it had a header included when going to dropdown mode.

XML

Spinner Design ||| Spinner Design - dropdown Navigate to the app > res > layout > activitymain.xml and add the below code to that file.
