【发布时间】:2025-12-07 23:10:01
【问题描述】:
我正在开发一个聊天应用程序。我想将 edittext 放在底部,然后将消息放在它上面。但是我有一个问题:
我不想将消息放在编辑文本和按钮的顶部。如何防止这种情况发生?这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ECECFB"
android:orientation="vertical" >
<ListView
android:id="@+id/message_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<EditText
android:id="@+id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/get_from_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="Gönder" />
</RelativeLayout>
</RelativeLayout>
我还有一个问题。我怎样才能像其他聊天应用一样做消息列表系统?我的意思是当我发送一条消息时,这条消息放在列表的底部而不是顶部。现在在我的 xml 中它放在顶部。像这样:
【问题讨论】: