use*_*084 1 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"
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>
Run Code Online (Sandbox Code Playgroud)
每当键盘发生故障时,列表视图应该占据整个屏幕,并且每当用户开始键入时它应该在键盘上方.

谢谢.
尝试将此代码放在与您的活动相关的androidmanifest.xml中
机器人:windowSoftInputMode = "adjustResize | stateAlwaysVisible"
喜欢这个
<activity
android:name="com.geeklabs.footmark.activity.CaptureActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label=""
android:windowSoftInputMode="adjustResize|stateAlwaysVisible"
/>
Run Code Online (Sandbox Code Playgroud)
以上活动例如如何放置
| 归档时间: |
|
| 查看次数: |
971 次 |
| 最近记录: |