我正在尝试在我的应用程序中使用AutoCompleteTextView,但是当建议的数量只有一个并且建议的文本超过1行(多行)时,只能看到单行 . 隐藏文本显示在滚动上 . 我想要做的是,当存在单个建议时,弹出窗口下的建议内容应该完全可见而不需要滚动 . 为了达到这个目的,我创建了一个自定义xml,看起来像这样 -

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:scrollbars="none">

    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/item"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="8dp"
        android:scrollbars="none"/>

</LinearLayout>

并且AutoCompleteTextView从这个xml中膨胀 -

<?xml version="1.0" encoding="utf-8"?>
<AutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/selector_material_single_line_edit_text"
    android:maxLines="1"
    android:paddingBottom="2dp"
    android:paddingTop="4dp"
    android:singleLine="true"
    android:textColorHighlight="@color/primary_material"
    android:textCursorDrawable="@drawable/shape_text_cursor"
    tools:ignore="LabelFor"/>

但文本无法正确显示并显示滚动 . 当建议中的项目数量为两个或更多时,同样的工作正常 . 我怎样才能解决这个问题?