Android的:如何改变ListView的高度动态每当手机的键盘弹出还是降? [英] Android: How to change height of ListView dynamically whenever the phone's keyboard pops up or goes down?

查看:118
本文介绍了Android的:如何改变ListView的高度动态每当手机的键盘弹出还是降?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个应用程序,它可以让用户聊天。用于显示聊天消息,我使用的ListView来显示列表项的消息。
我想只要键盘弹出或下降ListView控件进行相应的调整。

I have made an application which lets user chat. For showing the chat messages I am using ListView to display the messages in List items. I want the ListView to adjust accordingly whenever the keyboard pops up or goes down.

<?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控件应该占据整个屏幕,它应该上去,每当用户开始敲击键盘的上方。结果

The listview should occupy the whole screen whenever the keyboard goes down and it should go up above the keyboard whenever user begins typing.

感谢。

推荐答案

尝试把这个code在AndroidManifest.xml这是关系到你的活动

Try to place this code in androidmanifest.xml which is related to your activity

安卓windowSoftInputMode =adjustResize | stateAlwaysVisible

android:windowSoftInputMode="adjustResize|stateAlwaysVisible"

像这样

 <activity
            android:name="com.geeklabs.footmark.activity.CaptureActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label=""
            android:windowSoftInputMode="adjustResize|stateAlwaysVisible"
           />

这上面,例如活动如何放置

this above activity for example how to place

这篇关于Android的:如何改变ListView的高度动态每当手机的键盘弹出还是降?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆