如何与Android中包含的布局中的视图元素对齐

如何与Android中包含的布局中的视图元素对齐,android,android-layout,android-ui,Android,Android Layout,Android Ui,我想将当前布局中的视图元素与我在Android中通过标记包含的视图元素对齐 Layout1:(Layout1.xml) 布局2: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_hei

我想将当前布局中的视图元素与我在Android中通过标记包含的视图元素对齐

Layout1:(Layout1.xml)


布局2:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include
        android:id="@+id/includedLayout"
        layout="@layout/Layout1" />

    <View
        android:id="@+id/seperator"
        android:layout_width="wrap_content"
        android:layout_height="1dp"
        android:alpha="0.3"
        android:background="#FFFFFF" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <!-- I want to align this layout with relative layout present in the 
        Layout1.xml file which is included above -->

    </LinearLayout>

</LinearLayout>

我想将Layout2.xml中的第二个LinearLayout与Layout1.xml文件中的RelativeLayout对齐,该文件包含在Layout2.xml文件中

如果有人知道解决办法,请告诉我


谢谢。

您可以尝试将要对齐的布局部分放入另一个文件中,并仅将该文件包含在your layout2.xml中,并在layout2.xml中手动编码重新播放部分。 我的意思是 `


`

将此部分插入到另一个单独的文件中,并手动将imageview添加到layout2.xml

是否要将该线性布局与文本视图对齐?你能说得更清楚些吗?如果想将Layout2.xml文件中的第二个LinearLayout与Layout1.xml文件中的RelativeLayout对齐[上面粘贴的代码只是一个示例,此RelativeLayout可以包含更多视图,而不仅仅是文本视图]。谢谢,但重复使用的目的消失了:),我想重新使用包括图像视图在内的视图。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include
        android:id="@+id/includedLayout"
        layout="@layout/Layout1" />

    <View
        android:id="@+id/seperator"
        android:layout_width="wrap_content"
        android:layout_height="1dp"
        android:alpha="0.3"
        android:background="#FFFFFF" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <!-- I want to align this layout with relative layout present in the 
        Layout1.xml file which is included above -->

    </LinearLayout>

</LinearLayout>
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:gravity="bottom"
        android:paddingLeft="8dp"
        android:paddingTop="6dp"
        android:text="@string/textview1"
    />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:text="@string/textView2"
    />
</RelativeLayout>`