我正在开发一个聊天应用程序,我想把编辑文本放在底部,然后把消息放在it.But之上,我有一个问题:

我不想把消息放在编辑文本的顶部,button.How我能阻止这种情况吗?这是我的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>我还有一个question.How,我可以像其他聊天应用程序一样做消息列表系统吗?我的意思是,当我将这个消息发送到列表的底部,而不是我的xml中的top.Now时,它会把这个消息放在top.Like上:

发布于 2014-10-02 10:11:27
将ListView设置在EditText布局之上。您的布局如下:
<?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">
 <RelativeLayout 
        android:id="@+id/bottom_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
        <EditText
        android:id="@+id/message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" /> 
        <Button
        android:id="@+id/get_from_user"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:text="Gönder" />
    </RelativeLayout>
     <ListView
        android:id="@+id/message_list"
        android:layout_above="@id/bottom_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>至于你的第二个问题,
android:stackFromBottom="true"
android:transcriptMode="normal"到ListView
发布于 2014-10-02 10:08:36
第一个问题:您需要设置RelativeLayout
android:bellow="@+id/message_list"2问题:您需要设置ListView:
android:stackFromBottom="true"
android:transcriptMode="normal"最后的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:stackFromBottom="true"
        android:transcriptMode="normal"/>
 <RelativeLayout
        android:bellow="@+id/message_list"
        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>发布于 2014-10-02 10:08:54
例如,添加
android:layout_below="@id/message_list"对您的内部RelativeLayout进行约束,以约束ListView和底部RelativeLayout之间的关系,而不是将它们放置在对方的上面。
https://stackoverflow.com/questions/26158566
复制相似问题