【发布时间】:2014-09-28 15:16:11
【问题描述】:
当键盘可见时,我看不到 ListView 前几行的内容。
我花了一天的时间尝试各种布局代码以及我自己的代码来解决这个问题,现在我对这个问题有了更多的了解,可以帮助别人帮助我解决它。
问题是,如果我将列表视图(或其容器)的高度指定为 fill_parent,那么这会让 android 认为列表视图的底部(屏幕底部)是显示在键盘上方的部分,即使那里还没有显示实际内容。由于某种原因,我无法将事件滑到列表内容的开头。指定 just wrap content 只会按预期显示一个显示列表的小区域。
这是我最新的布局代码(所有尝试都会产生相同的问题)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/RelativeLayoutchat"
>
<LinearLayout
android:orientation="horizontal"
android:gravity ="clip_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true">
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/MessagesListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:transcriptMode="alwaysScroll"
android:divider="#000000"
android:clickable="false"
android:layout_weight="9"
android:cacheColorHint="#00000000"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
style="@android:style/ButtonBar"
android:gravity="center"
android:paddingLeft="3dip"
android:paddingTop="3dip"
android:paddingRight="3dip">
<EditText
android:id="@+id/msgBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="5"
android:enabled="true"
android:textSize="17sp"
android:maxLength="150"/>
<Button
android:id="@+id/sendbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="send"
android:layout_weight="4"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
非常感谢任何帮助。
【问题讨论】:
-
我在相关活动标签中也有 android:windowSoftInputMode="adjustPan"。
-
我已经解决了这个问题,但又产生了另一个问题。问题在于将活动设为全屏。我删除了代码,当显示键盘时,我可以滚动到列表的最顶部。但我真的希望在我的应用程序中全屏显示,所以有人知道解决方案是什么吗?
标签: android android-layout android-widget