Như bạn đã nói, hãy đặt cả hai phần tử bên trong RelativeLayout.
Sau đó, thiết lập "center_horizontal" tài sản của cả hai yếu tố là true, và sau đó thiết lập các "dưới" tài sản của các yếu tố màu xanh lá cây để id của phần tử đen.
Dưới đây là ví dụ hoàn chỉnh:
<?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" >
<View
android:id="@+id/view1"
android:layout_width="100dp"
android:layout_height="40dp"
android:background="@color/Black"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<View
android:id="@+id/view2"
android:layout_height="100dp"
android:layout_below="@+id/view1"
android:background="@color/Green"
android:layout_centerHorizontal="true" />
</RelativeLayout>
("center_vertical" là kinda không bắt buộc)
Hoặc đây, không phụ thuộc vào xem vị trí khác:
<?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" >
<View
android:id="@+id/view1"
android:layout_width="100dp"
android:layout_height="40dp"
android:background="@color/Black"
android:layout_centerVertical="true" />
<View
android:id="@+id/view2"
android:layout_width="40dp"
android:layout_height="100dp"
android:layout_below="@+id/view1"
android:layout_alignLeft="@+id/view1"
android:layout_alignRight="@+id/view1"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="@color/Green" />
</RelativeLayout>
(Trong trường hợp này, các lề sẽ xác định chiều rộng Lượt xem thứ hai)
Đây là kết quả cuối cùng:

Nguồn
2013-08-26 20:31:30
thể trùng lặp của [Android alignCenter Layout tương đối từ cái nhìn khác] (http://stackoverflow.com/questions/5487864/android-relative-layout-aligncenter-from -another-view) – tir38