2012-07-19 38 views
0

我正在开发需要具有功能模拟器的应用程序,就像构建在Android SMS Messenger中一样。如何克隆Android SMS视图

我试着做到以下几点:

<?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线得到扩展,还按钮过于扩大。 那么如何让按钮的高度固定?

回答

1
<Button 
    a:layout_height="0dip" 

意味着它会自动调整,尽量将它设置为wrap_content

+0

谢谢! ...我还必须设置:layout_height =“wrap_content” – user836026 2012-07-19 18:11:22