将自定义适配器设置为AutoCompleteTextView后,它显示不同的颜色。
<style name="generalExposedDropdownMenu" parent="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
<item name="boxStrokeColor">@color/text_input_layout_stroke_color</item>
<item name="hintTextColor">@color/dark_gray</item>
<item name="fontFamily">@font/nunito_regular</item>
<item name="android:textSize">12sp</item>
<item name="endIconTint">@color/dark_gray</item>
<item name="android:textColorHint">@color/dark_gray</item>
</style>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/relationship_textview"
style="@style/generalExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/picker_relationship">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
/>
val adapter = ArrayAdapter(this, R.layout.list_item, model.relationshipStatuses)
(relationshipTextview.editText as? AutoCompleteTextView)?.setAdapter(adapter)
列表项:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:ellipsize="end"
android:background="@color/white"
android:maxLines="1"
android:textAppearance="?attr/textAppearanceBodyLarge"
/>
1条答案
按热度按时间omqzjyyz1#
AutoCompleteTextView - How to remove margin from top and bottom?