Kotlin - Programmatically Created Spinner Dropdown Shows Underline And Arrow In Dropdown
Why do I get this weird dropdown behaviour whenever I use a custom text view for my Spinner? The dropdown seems to be obtaining the underline and arrow drawable for some reason, wh
Solution 1:
okay I managed to find out pretty cheap solution but it seems to work. just put your spinner creation logic in xml, say like that :
<Spinner
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:id="@+id/mySpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
and then inflate it in your layout from code, you would do it from activity like that :
layoutInflater.inflate(R.layout.item, frameLayout)
val arrayAdapter = ArrayAdapter(this, R.layout.support_simple_spinner_dropdown_item, spinnerItems)
arrayAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item)
mySpinner.adapter = arrayAdapter
Post a Comment for "Kotlin - Programmatically Created Spinner Dropdown Shows Underline And Arrow In Dropdown"