I am using AutoCompleteTextView
with custom item_layout. If layout_width
is not match_parent
there is a scrollbar showing even I have only one hint when hint is too big. But if we use width match_parent
there is no scrollbar. I want to use limited width for AutoCompleteTextView
anchor without that annoying scroll.
This is the code.
item_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:minHeight="48dp">
<TextView
android:id="@+id/autocomplete_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:paddingLeft="12dp" />
</LinearLayout>
main.xml with limited width(200dp for example)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/anchor"
android:layout_width="200dp"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/auto_complete"
android:layout_width="match_parent"
android:layout_height="40dp"
android:completionThreshold="1"
android:dropDownAnchor="@id/anchor"/>
</LinearLayout>
Result with limited width of anchor
main.xml width=match_parent
<LinearLayout
android:id="@+id/anchor"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/auto_complete"
android:layout_width="match_parent"
android:layout_height="40dp"
android:completionThreshold="1"
android:dropDownAnchor="@id/anchor"/>
</LinearLayout>
Result with width="match_parent" anchor parameter no scrollBar!