有一行有两个组件EditText和Button,Button靠最右,EditText宽度从最左到Button的左边,
这个用相对布局,要怎么实现?

解决方案 »

  1.   


    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent">
        <Button 
        android:id="@+id/myButton"
        android:layout_alignParentRight="true"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        />
        <EditText 
        android:id="@+id/myEdit"
        android:layout_toLeftOf="@id/myButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
    </RelativeLayout>
      

  2.   

    同意楼上,不过按LZ要求应该是android:orientation="horizontal"
      

  3.   

    2楼正解,不过如果是2.1以下的要改一下EditText的属性android:layout_width="fill_parent"