Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:如何在手机键盘弹出或关闭时动态更改ListView的高度?_Android_Android Layout_Android Listview_Android Xml - Fatal编程技术网

Android:如何在手机键盘弹出或关闭时动态更改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

我已经做了一个应用程序,让用户聊天。为了显示聊天信息,我使用ListView在列表项中显示信息。 每当键盘弹出或关闭时,我希望ListView能够相应地进行调整

<?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"
           />
以上活动举例说明如何放置