Android includes a layout under the element

I would like to create a layout like in the image. He did not turn it on, so the code is very long. I want to create a layout for each BOX and include it in the main layout, one below the other.

enter image description here

The problem is that the XML file layout of this type is very long. Therefore, I would like to use a layout and create a new layout, which will then include, for example:

I have a RelativeLayout and I have an ImageView for row1, below I want to create a window in this method to reduce the code:

<include layout = "box1"
layoutBelow = "linea1"
/>

And the same for field 2:

<include layout = "box2"
layoutBelow = "linea2"
/>

But the layout that I include does not align as I would like. The layout is superimposed on the existing one.

+4
5

:

<!-- LINE SEPARATOR 1-->
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/logo"
    android:id="@+id/linea1"
    android:background="@drawable/linea"
    />

<!-- BOX1 -->
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/linea1"
    >

    <include
        layout="@layout/box1"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"

        />
</RelativeLayout>

<!-- LINE SEPARATOR 2-->
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/logo"
    android:id="@+id/linea2"
    android:background="@drawable/linea"
    />

<!-- BOX2 -->
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/linea2"
    >

    <include
        layout="@layout/box2"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"

        />
</RelativeLayout>

:

enter image description here

:)

+12

Android Studio , , layout_width layout_height include, layout_below .

+2

, , id, linea1. :

<LinearLayout
    android:id="@+id/id_linea1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    ...
</LinearLayout>

<include 
         layout="@layout/box1"
         android:layout_below="@id/id_linea1"
        />
+2

linea2 box1 RelativeLayout.

, , LinearLayout .

0

:

    <include
    layout="@layout/content_home"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/id_linea1" />
0

All Articles