我正在尝试创建一个非常基本的聊天屏幕,其中包含显示文本的 ListView 和底部的 EditText,以及 EditText 右侧的“发送”按钮。一切正常,但是当我单击 EditText 时,虚拟键盘会覆盖它。屏幕稍微向上平移,但不足以在键盘上方可见。我的 list 中有“adjustPan”标签,也试过“adjustResize”标签无济于事。我猜这与我的布局设置方式有关,但老实说我不知道。请帮忙!
当前布局...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_height="0dip"
android:layout_width="fill_parent"
android:layout_weight="1"
android:stackFromBottom="true">
</ListView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/sendMessageBox"
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical"
android:maxLines="4"
android:text=""
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="1000"
android:hint="Type your message..."
android:imeOptions="actionSend"/>
<Button android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Send"/>
</LinearLayout>
最佳答案
经过大量搜索,显然这就是我所说的错误。如果您使用全屏标签(从 Activity 中删除状态栏),则不能在不将 Activity 包装在 ScrollView 中的情况下使用“adjustResize”。对我来说不幸的是,我正在使用 ListView,这会产生另一个问题。我厌倦了它,可能会放弃该 Activity 的全屏。
关于android - adjustPan 不阻止键盘覆盖 EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4558810/