有沒有辦法將佈局與另一個佈局的子對齊? 我已經創建了一個例子:將佈局與另一個佈局的子對齊
<?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" >
<RelativeLayout
android:id="@+id/rel1"
android:layout_width="200dp"
android:layout_height="match_parent"
android:background="#7F000000"
android:gravity="center"
android:layout_alignParentEnd="true">
<View
android:id="@+id/view"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:background="#00FF00"/>
<View
android:id="@+id/view2"
android:layout_width="50dp"
android:layout_below="@+id/view"
android:layout_height="50dp"
android:background="#00FF00"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rel2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#7F0000FF"
android:layout_alignTop="@+id/view2">
</RelativeLayout>
</RelativeLayout>
在這裏,我嘗試對準RelativeLayout的REL2與視圖2的頂部上方,但RelativeLayout的不支持這樣做。
我:
我想:
感謝。
只需**不嵌套**其他2個RelativeLayouts的主要原因之一。完善。和**更快**。 –
你想rel2的寬度匹配父母或寬度rel1。? –
你有沒有在下面檢查http://stackoverflow.com/a/36837747/2826147答案? –