Android:如何在手机键盘弹出或关闭时动态更改ListView的高度?
我已经做了一个应用程序,让用户聊天。为了显示聊天信息,我使用ListView在列表项中显示信息。 每当键盘弹出或关闭时,我希望ListView能够相应地进行调整Android:如何在手机键盘弹出或关闭时动态更改ListView的高度?,android,android-layout,android-listview,android-xml,Android,Android Layout,Android Listview,Android Xml,我已经做了一个应用程序,让用户聊天。为了显示聊天信息,我使用ListView在列表项中显示信息。 每当键盘弹出或关闭时,我希望ListView能够相应地进行调整 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" an
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<EditText
android:id="@+id/message_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:ems="10"
android:hint="Enter your message..."
android:maxLength="20"
android:paddingLeft="22dp" />
<ImageButton
android:id="@+id/send_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/ok"/>
</RelativeLayout>
<ListView
android:id="@+id/message_listView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:stackFromBottom="true">
</ListView>
</RelativeLayout>
每当键盘下降时,listview应该占据整个屏幕,每当用户开始打字时,listview应该上升到键盘上方。
谢谢。尝试将此代码放在与您的活动相关的androidmanifest.xml中 android:WindowsOfInputMode=adjustResize |状态始终可见 像这样
<activity
android:name="com.geeklabs.footmark.activity.CaptureActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label=""
android:windowSoftInputMode="adjustResize|stateAlwaysVisible"
/>
上述活动(例如如何放置)尝试将此代码放置在与您的活动相关的androidmanifest.xml中 android:WindowsOfInputMode=adjustResize |状态始终可见 像这样
<activity
android:name="com.geeklabs.footmark.activity.CaptureActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label=""
android:windowSoftInputMode="adjustResize|stateAlwaysVisible"
/>
以上活动举例说明如何放置