我有一个RelativeLayout置于顶部,紧接着在中心我有一个ListView, 最后在底部我有另一个RelativeLayout,里面有EditText和Button。
我希望当我点击EditText并且输入法(虚拟键盘)出现时,ListView可以自适应大小。如果我在manifest中加入adjustResize,那么ListView将会被调整大小以腾出空间留给输入法,但是下面的RelativeLayout会被输入法遮挡,无法看到我正在输入的内容。如果我加入adjustPan,那么输入法会将所有内容上推,ListView不会被调整大小,而我也失去了顶部的RelativeLayout。
我的代码:
我希望当我点击EditText并且输入法(虚拟键盘)出现时,ListView可以自适应大小。如果我在manifest中加入adjustResize,那么ListView将会被调整大小以腾出空间留给输入法,但是下面的RelativeLayout会被输入法遮挡,无法看到我正在输入的内容。如果我加入adjustPan,那么输入法会将所有内容上推,ListView不会被调整大小,而我也失去了顶部的RelativeLayout。
我的代码:
<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>