"inputType="none" doesn't work with Material Components ExposedDropdownMenu
Asked Answered
R

2

5

I'm trying do make a non-editable exposed dropdown menu, following the guide under "Implementing an exposed dropdown menu" found here: https://material.io/develop/android/components/text-fields/

However, it's still editable, even with "inputType="none"" on the AutoCompleteTextView.

Here's my xml:

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/textInputLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="24dp"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">

            <AutoCompleteTextView
                android:id="@+id/autoCompleteTextView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="none" />

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

Does anybody know why this doesn't work, even though it's in their official documentation and how to make this truly non-editable?

PS: "editable="false"" does solve the problem, but since this is depracted, I don't really want to use it

Redraft answered 3/5, 2020 at 20:23 Comment(0)
P
6

How about this:

android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="none|textNoSuggestions"
android:cursorVisible="false"
Petronella answered 3/5, 2020 at 20:33 Comment(1)
Thanks, it works! Though I removed the two focusable tags and added "showSoftInputOnFocus = false" in code, so the exposed dropdown menu will still be colored when focused.Redraft
T
0

This is an example of AutoCompleteTextView:-

                    <AutoCompleteTextView
                    android:id="@+id/autoComplete"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:inputType="none"
                    android:enabled="false"
                    android:padding="15dp" />
Tallahassee answered 5/8, 2022 at 20:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.