10

I want to remove dropdown arrow which is created by AutoCompleteTextView when I use TextInputLayout and use Style: ExposedDropdownMenu

Added image about what I want to remove

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>
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • It's AutoCompleteTextView –  Sep 21 '19 at 09:17
  • @pskink Please read my code too, AutoCompletetextview is acting the same here, the same design. Have a look here: https://material.io/develop/android/components/menu/ –  Sep 21 '19 at 09:30

3 Answers3

28

If you would like to avoid the dropdown icon just use the app:endIconMode attribute.

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

Before and after:

enter image description hereenter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
1

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. 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. Code 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"

Excuse my level of English!!

Yaqoob Bhatti
  • 1,271
  • 3
  • 14
  • 30
0

Besides doing this in your layout.xml there is also the opportunity to do it programmatically. Therefor you need an instance of the surrounding TextInputLayout instead of the AutoCompleteTextView.

To remove the drop down button, just run

textInputLayout.setEndIconMode(TextInputLayout.END_ICON_NONE);

To activate the drop down button, just run

textInputLayout.setEndIconMode(TextInputLayout.END_ICON_DROPDOWN_MENU);
Marcel Hofgesang
  • 951
  • 1
  • 15
  • 36