我有TextInputLayout,其中我使用文本自动完成,并实现了一个性别下拉菜单。问题是,在下拉式项目的背景中,白色显示在顶部和底部。我已经给了背景颜色黄色。

这是我的XML
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayoutGender"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="70dp"
android:layout_marginEnd="32dp"
android:hint="Gender"
android:textColorHint="#858585"
app:boxCornerRadiusBottomEnd="45dp"
app:boxCornerRadiusBottomStart="45dp"
app:boxCornerRadiusTopEnd="45dp"
app:boxCornerRadiusTopStart="45dp"
app:boxStrokeColor="@color/edit_textbox_color"
app:boxStrokeWidth="2dp"
app:endIconTint="#FFC153"
app:hintTextColor="@color/yellow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewInformation"
tools:ignore="MissingConstraints">
<AutoCompleteTextView
android:id="@+id/gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/sex"
android:drawablePadding="16dp"
android:fontFamily="@font/montserrat_medium"
android:inputType="textNoSuggestions"
android:textColor="@color/yellow" />
</com.google.android.material.textfield.TextInputLayout>此I用于下拉项
<com.google.android.material.textview.MaterialTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/textView"
android:background="@color/yellow"
android:textColor="@color/black"
android:padding="14dp"
>
</com.google.android.material.textview.MaterialTextView>发布于 2021-06-22 14:27:52
尝试以编程方式应用背景可绘制,如下所示:
autoCompleteTextView.setDropDownBackgroundDrawable(
context.getResources().getDrawable(R.drawable.yellow_drawable));创建纯黄颜色的yellow_drawable.xml。
发布于 2021-06-22 14:33:08
https://stackoverflow.com/questions/68078485
复制相似问题