我在顶部有一个relativeLayout,然后在下面的中心有一个ListView,最后在底部我有另一个relativeLayout,里面有一个EditText和一个Button。
我希望当我单击 EditText 并出现 IME(虚拟键盘)时,可以调整 ListView 的大小。如果我将 adjustmentResize 放入清单中,Listview 会调整大小,为 IME 留出空间,但下面带有 EditText 的相对布局被 IME 覆盖,我看不到我在写什么。如果我放置 adjustmentPan,键盘会将所有内容向上推,ListView 不会调整大小,并且我会松开顶部的relativelayout。
My Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/application_background"
android:paddingLeft="15px"
android:paddingRight="15px"
android:paddingTop="15px"
android:paddingBottom="15px">
<RelativeLayout
android:id="@+id/rlyParentPost"
android:orientation="vertical"
android:layout_width="450px"
android:layout_height="85px"
android:background="@drawable/app_gradient_color"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/imgUserOfParent"
android:layout_marginLeft="10px"
android:layout_marginTop="10px"
android:background="@drawable/userfeed"
android:layout_width="64px"
android:layout_height="64px"
android:layout_below="@+id/logoImg">
</ImageView>
<TextView
android:layout_below="@+id/logoImg"
android:layout_toRightOf="@+id/imgUserOfParent"
android:id="@+id/lblNameOfParent"
android:textSize="17px"
android:textStyle="bold"
android:layout_marginLeft="5dip"
android:layout_marginTop="11dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff">
</TextView>
<TextView
android:layout_below="@+id/lblNameOfParent"
android:layout_toRightOf="@+id/imgUserOfParent"
android:id="@+id/lblBodyOfParent"
android:textColor="#ffffff"
android:textSize="17px"
android:layout_marginLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:layout_below="@+id/lblBodyOfParent"
android:layout_toRightOf="@+id/imgUserOfParent"
android:id="@+id/lblDateOfParent"
android:textColor="#70ccff"
android:textSize="11px"
android:layout_marginLeft="7dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlyParentPost"
android:id="@+id/contentLayout">
<ListView
android:isScrollContainer="true"
android:id="@+id/lsvComments"
android:layout_height="515px"
android:layout_width="450px"
android:background="#ffffff"
android:listSelector="@drawable/multi_white_color"
android:drawSelectorOnTop="false"
android:divider="#9aa5ac"
android:cacheColorHint="#00000000"
android:dividerHeight="1px">
</ListView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_below="@+id/lsvComments"
android:background="@drawable/app_gradient_comments"
android:id="@+id/contentLayout">
<EditText
android:inputType="text"
android:id="@+id/txtComment"
android:hint="What are you working on?"
android:textSize="22px"
android:layout_marginLeft="8px"
android:layout_height="72px"
android:layout_width="344px">
</EditText>
<Button
android:layout_toRightOf="@+id/txtComment"
android:id="@+id/cmdShare"
android:layout_width="79px"
android:layout_height="65px"
android:background="@drawable/feed_comments_multi_stage"
android:layout_marginLeft="7px">
</Button>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
您不应该使用明确的像素值设置layout_width和layout_heights。相反,请根据需要使用wrap_parent 或fill_parent。
如果您希望文本视图等内容具有特定的宽度,请使用 dpi 单位,它将在不同的屏幕分辨率上正确调整。
关于您的特定虚拟键盘问题,我会尝试设置 ListView 以使其占用剩余空间。
--将除ListView之外的所有内容的高度设置为wrap_parent
--设置ListView为fill_parent,
ListView 应该占用尽可能多的可用空间,因此当您要求它调整大小时会缩小。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)