从 AutoCompleteTextView 中删除下拉箭头

Remove dropdown arrow from AutoCompleteTextView

我想删除在我使用 TextInputLayout 时由 AutoCompleteTextView 创建的下拉箭头并使用样式:ExposedDropdownMenu

下面是我的代码:

<com.google.android.material.textfield.TextInputLayout
        android:layout_marginTop="10dp"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
        android:hint="Marital Status"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:boxStrokeColor="@color/colorPrimaryDark">

        <AutoCompleteTextView
            android:background="@null"
            android:focusable="false"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/edt_marital" />
    </com.google.android.material.textfield.TextInputLayout>

如果您想避免下拉图标,只需使用 app:endIconMode 属性即可。

<com.google.android.material.textfield.TextInputLayout
      style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
      app:endIconMode="none"
      ...>

之前和之后:

大家好,搜索了很多却发现很少。我正在努力实现我想要的,我想与你分享经验和结果。 正如 Material Design 文档所说。

结果Image Dropdown Menu 类似于 Spinner,遵循文档。下一个代码:

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/txtAnswer"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_top_15dp"
                android:layout_marginEnd="10dp"
                app:endIconDrawable="@drawable/ic_arrow_down"
                app:hintTextAppearance="@style/styleFilterLabelLatoRegular"
                app:layout_constraintEnd_toStartOf="@+id/txtAssignedTo"
                app:layout_constraintStart_toStartOf="@+id/guideLineBegin"
                app:layout_constraintTop_toBottomOf="@+id/txtSearchQuestionnaire">

                <AutoCompleteTextView
                    android:id="@+id/actvTypesAnswer"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="none"
                    android:hint="@string/text_answer" />

现在是 AutoCompleteTextView 的预期结果 Image AutoCompleteTextView。代码 xml.

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/txtSearchQuestionnaire"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_top_15dp"
                app:endIconMode="none"
                app:hintTextAppearance="@style/styleFilterLabelLatoRegular"
                app:layout_constraintEnd_toEndOf="@id/guideLineEnd"
                app:layout_constraintStart_toStartOf="@+id/guideLineBegin"
                app:layout_constraintTop_toBottomOf="@+id/txtPeriodActivation">

                <AutoCompleteTextView
                    android:id="@+id/actvNameQuestionnaire"
                    style="@style/textAppearanceSettingInputEdittextFilter.Enabled"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:drawableEnd="@drawable/ic_search"
                    android:hint="@string/text_search_name_questionnaire" />

            </com.google.android.material.textfield.TextInputLayout>

唯一的变化是在 TextInputLayout 中添加属性 app: endIconMode = "none",在 AutoCompleteTextView 中添加属性 android: drawableEnd="@drawable/ic_search"

请问我的英语水平!!