如下代码让位于同一行的两个控件分别左对齐和右对齐:
<RelativeLayout xmlns:Android="http://schemas.android.com/apk/res/android" Android:background="@drawable/top" Android:layout_width="fill_parent" Android:layout_height="wrap_content" ><ImageView Android:id="@+file_browser/imgRefresh" Android:layout_width="wrap_content" Android:layout_height="wrap_content" Android:layout_marginLeft="10px" Android:src="@drawable/refresh" Android:layout_centerVertical="true" > </ImageView> <ImageView Android:id="@+file_browser/imgCheck" Android:layout_alignParentRight="true" Android:layout_width="wrap_content" Android:layout_height="wrap_content" Android:layout_marginRight="10px" Android:src="@drawable/close" Android:layout_centerVertical="true" > </ImageView> </RelativeLayout>