我正在尝试创建一个非常基本的聊天屏幕,其中包含一个显示文本的ListView和一个位于底部的EditText以及位于EditText右侧的"Send“按钮。一切都正常,但当我单击EditText时,虚拟键盘会覆盖它。屏幕平移了一点,但还不足以在键盘上方可见。我在清单中添加了"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>
发布于 2011-01-25 12:10:41
在做了大量的搜索之后,显然这就是我所说的bug。如果使用fullscreen标记(从活动中移除状态栏),则在不将活动包装在ScrollView中的情况下,不能使用"adjustResize“。不幸的是,对我来说,我使用的是ListView,这会造成另一个问题。我厌倦了把它搞得一团糟,很可能会放弃全屏的活动。
发布于 2014-01-23 04:53:19
在清单文件中,您需要设置适当的android:windowSoftInputMode属性。此属性从API 3开始有效。
<activity
...
android:windowSoftInputMode="adjustPan" >
</activity>选项包括:http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
发布于 2015-10-27 22:38:00
如果您为清单中的活动设置了android:windowSoftInputMode="adjustResize",则ScrollView (或其他可折叠的ViewGroups)将收缩以容纳软键盘。但是,如果您在活动的主题中设置了android:windowFullscreen="true",那么ScrollView将不会缩小,因为它会被强制填满整个屏幕。但是,在主题中设置android:fitsSystemWindows="false"也会导致adjustResize无法工作
https://stackoverflow.com/questions/4558810
复制相似问题