layout_below项目内包含布局

Raw*_*awr 8 android relativelayout android-layout

我试图想出一种方法来对齐布局中的项目相对于包含的布局中的项目.

这是一个直观的表示: 在此输入图像描述

这里是我正在寻找的示例代码(显然不起作用):
Main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <include
        android:id="@+id/info"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        layout="@layout/info" />
    //This would be the dark grey box
    <RelativeLayout
        android:layout_below="@id/item1">
    </RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

included.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="50dp">
    <ImageView
        android:id="@+id/item1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:paddingLeft="100dp"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)



我假设最好的方法是通过在代码中动态定位深灰色框,但我不知道从哪里开始.任何帮助都是极好的.

Yur*_*ury 7

你可以在你的包含下面做这个吗?像这样的东西(而不是item1使用信息):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <include
        android:id="@+id/info"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        layout="@layout/info" />
    //This would be the dark grey box
    <RelativeLayout
        android:layout_below="@id/info">
    </RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)