简体   繁体   English

从 AutoCompleteTextView 中删除下拉箭头

[英]Remove dropdown arrow from AutoCompleteTextView

I want to remove dropdown arrow which is created by AutoCompleteTextView when I use TextInputLayout and use Style: ExposedDropdownMenu当我使用TextInputLayout并使用 Style: ExposedDropdownMenu时,我想删除由AutoCompleteTextView创建的下拉箭头

添加了有关我要删除的内容的图片

Below is my code:下面是我的代码:

<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>

If you would like to avoid the dropdown icon just use the app:endIconMode attribute.如果您想避免下拉图标,只需使用app:endIconMode属性。

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

Before and after:之前和之后:

在此处输入图像描述 在此处输入图像描述

Hello guys, after having searched a lot and found little.大家好,经过大量搜索,发现很少。 I was trying to achieve how I wanted and I wanted to share the experience and result with you.我试图达到我想要的效果,我想和你分享经验和结果。 As the same Material Design documentation says.正如相同的材料设计文档所说。

A result Image Dropdown Menu similar to a Spinner, following the documentation.一个类似于 Spinner 的结果图像下拉菜单,遵循文档。 Next code:下一个代码:

<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" />

Now a result as expected from an AutoCompleteTextView Image AutoCompleteTextView .现在是 AutoCompleteTextView Image AutoCompleteTextView预期的结果。 Code xml.代码 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>

The only changes were to add the attribute app: endIconMode = "none" in TextInputLayout and in the AutoCompleteTextView the attribute android: drawableEnd = "@ drawable / ic_search"唯一的变化是在 TextInputLayout 和 AutoCompleteTextView 中添加属性 app: endIconMode = "none" 属性 android: drawableEnd = "@drawable / ic_search"

Excuse my level of English!!请原谅我的英语水平!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM