有没有办法将布局与另一个布局的子对齐? 我已经创建了一个例子:将布局与另一个布局的子对齐
<?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答案? –