0

我正在开发需要具有类似内置 Android SMS Messenger 功能的应用程序。

我尝试执行以下操作:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:a="http://schemas.android.com/apk/res/android"
                a:layout_width="fill_parent"
                a:layout_height="fill_parent">
    <LinearLayout
            a:orientation="vertical"
            a:layout_height="wrap_content"
            a:layout_width="fill_parent">
        <EditText
                a:id="@+id/smsRecipients"
                a:layout_height="wrap_content"
                a:layout_width="fill_parent"
                a:hint="@string/sms_to_whom"/>
        <Button
                a:layout_height="wrap_content"
                a:layout_width="fill_parent"
                a:text="@string/sms_contacts"
                />
    </LinearLayout>

    <LinearLayout a:layout_alignParentBottom="true"
                  a:orientation="horizontal"
                  a:layout_width="fill_parent"
                  a:layout_height="wrap_content"
                  a:paddingTop="5dip"
                  a:paddingBottom="5dip"
                  a:paddingLeft="5dip"
                  a:paddingRight="5dip"
                  a:background="#dcdcdc">
        <EditText
                a:id="@+id/smsBody"
                a:layout_width="0dip"
                a:layout_height="wrap_content"
                a:layout_weight="1.0"
                a:autoText="true"
                a:capitalize="sentences"
                a:nextFocusRight="@+id/send_button"
                a:hint="@string/sms_enter_message"
                a:maxLines="10"
                a:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
                a:imeOptions="actionSend|flagNoEnterAction"/>
        <LinearLayout a:orientation="vertical" a:layout_width="wrap_content" a:layout_height="fill_parent">
            <Button
                    a:id="@+id/smsSendButton"
                    a:layout_marginLeft="5dip"
                    a:layout_width="wrap_content"
                    a:layout_height="0dip"
                    a:layout_weight="1.0"
                    a:nextFocusLeft="@+id/smsBody"
                    a:text="@string/sms_send_abbr"
                    a:enabled="false"/>
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

它工作正常,除了当 EditText 扩展超过 1 行时,按钮也得到扩展。那么如何让按钮的高度固定呢?

4

1 回答 1

1
 <Button
   a:layout_height="0dip" 

表示它会自动调整大小,尝试将其设置为 wrap_content

于 2012-07-19T17:36:51.833 回答