![](/img/trans.png)
[英]android - AutoCompleteTextView dropDown height is not correct
[英]AutoCompleteTextView dropDown height is incorrect
我正在使用帶有自定義 item_layout 的AutoCompleteTextView
。 如果layout_width
不是match_parent
,當提示太大時,即使我只有一個提示,也會顯示一個滾動條。 但是如果我們使用寬度match_parent
則沒有滾動條。 我想為AutoCompleteTextView
錨點使用有限的寬度,而不需要那個煩人的滾動條。 這是代碼。
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寬度有限(例如 200dp)
<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>
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>
<AutoCompleteTextView
android:id="@+id/autocomplete_dogs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Autocomplete"
android:hint="Search dogs..."
android:dropDownAnchor="@+id/header"
android:dropDownWidth="match_parent"
/>
這是完整的指南AutocompleteTextView
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.