1

我想在屏幕底部对齐 aButton和 multiLine 。EditText他们都应该在彼此旁边。这两个目前都在一个LinearLayout. 我该怎么做呢?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" 
    android:orientation="vertical"
    android:weightSum="2">

    <LinearLayout
        android:id="@+id/linearlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#F5F5F5"
        android:orientation="horizontal" 
       >

        <TextView
            android:id="@+id/Text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="To:"
            android:textSize="15sp" />

        <EditText
            android:id="@+id/To"
            android:layout_width="153dp"
            android:layout_height="fill_parent"
            android:layout_weight="0.86"
            android:inputType="phone" />

        <Button
            android:id="@+id/Browse"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:text="+" />
    </LinearLayout>

     <ListView
            android:id="@+id/listview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"

            android:layout_below="@+id/linearlayout" />

<!-- 
            <TextView 
            android:id="@+id/awain"
            android:layout_width="wrap_content"
          android:layout_height="wrap_content"
            android:layout_below="@+id/linearlayout" 
            android:text="Listview"

            /> -->




    <RelativeLayout 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"


        >
           <LinearLayout
            android:orientation="horizontal"

            android:layout_width="fill_parent"
            android:layout_height="wrap_content">


            <EditText
                android:id="@+id/Message"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.75"

                android:inputType="textCapSentences|textMultiLine"
                android:maxLength="2000"
                android:maxLines="5"  />

      <Button
                android:id="@+id/send"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.25"
                android:minWidth="150dp"
                android:text="Send"
                android:layout_marginBottom="0dp"
                android:layout_alignParentBottom="true">

            </Button>





      </LinearLayout>


    </RelativeLayout>













</RelativeLayout>
4

3 回答 3

2
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:orientation="horizontal" >

<EditText 
    android:layout_height="wrap_content"
    android:layout_width="200dp"
    android:gravity="top"
    android:lines="3"
    android:layout_gravity="bottom"/>

<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:text="test"/>


</LinearLayout>
于 2013-07-05T11:16:13.997 回答
1

@user2552435

你使用RelativeLayout,将RelativeLayout改为LinearLayout

<RelativeLayout 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
于 2013-07-05T11:49:36.543 回答
1

您必须使用相对布局作为您的 Linerlayout 的父级

请参阅此处的示例..

<?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" >

  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/edittextid"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Your edit text"
        android:maxLines="3" />

    <Button
        android:id="@+id/buttonid"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button" />
  </LinearLayout>

</RelativeLayout>
于 2013-07-05T11:15:21.867 回答