Android 当只有一个建议时,AutoCompleteTextView建议隐藏在键盘下
我在Android项目中使用的是AutoCompleteTextView,除了以下内容外,几乎所有内容都正常工作: 当我只有一个建议要显示时,此建议隐藏在软键盘下。但是当我有多个建议时,它们会出现在软键盘上方(但不幸的是,不会出现在我的AutoCompleteTextView上方),我可以看到所有建议,如果有很多建议,可以滚动浏览 我尝试过修改android:dropDownHeight,但没有成功。我还尝试过设置android:WindowsOfInputMode=“adjustResize | adjustPan”,它可以工作(即使只有一个建议,我也可以看到所有建议),但它会扰乱我的布局,扭曲显示的所有内容 是否可以强制下拉建议始终显示在AutoCompleteTextView上方?否则我怎么能着手解决这个问题呢 以下是AutoCompleteTextView的XML:Android 当只有一个建议时,AutoCompleteTextView建议隐藏在键盘下,android,dropdown,android-softkeyboard,autocompletetextview,Android,Dropdown,Android Softkeyboard,Autocompletetextview,我在Android项目中使用的是AutoCompleteTextView,除了以下内容外,几乎所有内容都正常工作: 当我只有一个建议要显示时,此建议隐藏在软键盘下。但是当我有多个建议时,它们会出现在软键盘上方(但不幸的是,不会出现在我的AutoCompleteTextView上方),我可以看到所有建议,如果有很多建议,可以滚动浏览 我尝试过修改android:dropDownHeight,但没有成功。我还尝试过设置android:WindowsOfInputMode=“adjustResize
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:maxLines="1"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
android:ems="10"
android:inputType="text"
android:fontFamily="@font/poppins_bold"
android:textColor="@color/colorPrimary"
android:background="@drawable/backwithborder"
android:padding="8dp"
android:paddingLeft="12dp"
android:paddingStart="12dp"
android:maxLength="25"
android:dropDownAnchor="@id/givePointsToText"
android:layout_toRightOf="@id/pointsSpinner"
android:layout_toEndOf="@id/pointsSpinner"
android:layout_toLeftOf="@id/givePointsButton"
android:layout_toStartOf="@id/givePointsButton"
android:layout_centerVertical="true"
android:dropDownWidth="match_parent"/>
将其添加到您的清单文件中:
android:windowSoftInputMode="adjustPan|adjustResize"
像这样:
<activity
android:name="com.example.adjustscroll.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan|adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
将其添加到您的清单文件中:
android:windowSoftInputMode="adjustPan|adjustResize"
像这样:
<activity
android:name="com.example.adjustscroll.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan|adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我通过将AutoCompleteTextView移到屏幕顶部来“修复”我的问题,这样建议下拉列表只在一侧,并且有放置下拉列表和软键盘的空间
丑陋的解决方案,但这是我唯一能解决问题的方法。我通过将AutoCompleteTextView移到屏幕顶部来“修复”我的问题,这样建议下拉列表只在一侧,并且有放置下拉列表和软键盘的空间
难看的解决方案,但这是我唯一能解决问题的办法。我尝试了这个方法,效果很好,但
adjustResize
扭曲了屏幕上的所有内容。有没有办法解决这个问题?我不能说,因为你还没有发布完整的布局文件。键盘采用全屏幕宽度。无法理解为什么只有“左”部分变形。左边是什么?右边是什么?我的意思是“屏幕上剩余的一切都被扭曲了”,就像我的ImageView一样。我通过将AutoCompleteTextView移到屏幕顶部来“修复”我的问题。我尝试了这个方法,但它可以工作,但是adjustResize
会扭曲屏幕上的所有内容。有没有办法解决这个问题?我不能说,因为你还没有发布完整的布局文件。键盘采用全屏幕宽度。无法理解为什么只有“左”部分变形。左边是什么?右边是什么?我的意思是“屏幕上剩余的一切都被扭曲了”,就像我的ImageView一样。我通过将AutoCompleteTextView移到屏幕顶部来“修复”我的问题。