android 视图顶部和底部的不同颜色由具有ExposedDropdownMenu样式的TextInputLayout显示

1u4esq0p  于 2023-01-11  发布在  Android
关注(0)|答案(1)|浏览(165)

将自定义适配器设置为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"
    />
omqzjyyz

omqzjyyz1#

<dimen name="mtrl_exposed_dropdown_menu_popup_vertical_padding" tools:override="true">0dp</dimen>

AutoCompleteTextView - How to remove margin from top and bottom?

相关问题