可能重复Android : autocompletetextview, suggestion list displays above the textview?
当建议列表被用户滚动但我总是打开侧面时,我完全试图在键盘上显示重叠的建议列表 .
我来这里是这样的
这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sl"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".SuggestionListActivity"
android:windowSoftInputMode="adjustResize|adjustPan|stateHidden">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是我的main.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" android:padding="10dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:layout_margin="10dp"/>
<TextView android:layout_margin="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is testing for the auto complete textview in this application to display suggestion list overlapping on keyboard." />
<AutoCompleteTextView android:id="@+id/autocomplete"
android:layout_width="fill_parent" android:layout_margin="5dp"
android:layout_height="wrap_content" android:hint="Search"
android:layout_marginLeft="5dp" android:dropDownHeight="300dp"
android:inputType="textAutoComplete" android:singleLine="true"
/>
</LinearLayout>
如何在列表聚焦时在此代码中执行以显示键盘上的建议 .
6 回答
我以前遇到过这个问题 . 对我来说,
AutocompleteTextView
上面的屏幕空间比下面的更多(在"normal"设备上测试),因此列表向上打开 . 我稍微调整了我的布局,以便AutocompleteTextView
下面有更多的空间,它开始向下打开 . 这就是为我解决的问题 .您可以调整布局,以便
AutoCompleteTextView
下面有更多空间要么
您可以更改下拉高度
android:dropDownHeight
并设置一些高值,这将在scrollView
内部和AutoCompleteTextView
靠近顶部时起作用 .要显示焦点上的选项列表,请执行以下操作
当用户关注
AutoCompleteTextView
时,这将显示一个选项列表诀窍是确保所需的下拉高度永远不会大于下面的可用空间 . 我的方法是创建一个覆盖
showDropDown
的子类:然后在你的布局中使用它,例如:
调整
MINIMAL_HEIGHT
以满足您的要求 - 如果有's no or very little space below, it'可能最好不要强制解决问题 .只需将
android:dropDownHeight="100dp"
添加到布局文件中的AutoCompleteTextView
标签就是我猜的最佳解决方案!它只会控制下降高度的高度,让我们滚动!这是我的解决方案
键盘显示建议列表后面列出了AutoCompletionTextView .
在Scrollview中设置包含Autocompletetextview的完整版面
这将解决您的问题!