あなた自身が言ったように、RelativeLayoutの中に両方の要素を入れてください。
そして、真の両方の要素の「center_horizontal」プロパティを設定し、黒の要素のIDに緑色要素の「以下」プロパティを設定します。
ここでは完全な例である:
<?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は" ちょっと省略可能です)
それともここで、かかわらず、他のビューの位置の:
<?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>
(中この場合、マージンは2番目のビュー幅を定義します)
これは最終的な結果である:[他のビューからのAndroid相対レイアウトalignCenter]の
![enter image description here](https://i.stack.imgur.com/uUTJl.png)
可能重複(http://stackoverflow.com/questions/5487864/android-relative-layout-aligncenter-from -another-view) – tir38