Android include layout below element

Alberto Deidda

I would like to create a layout as in the image. It did not include him, 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 a layout of this type is very long. So I would use includes layout and create a new layout which then repeatedly will include, for example:

I have a RelativeLayout, and I have an ImageView for the line1, below I want to design the box in this method to reduce the code:

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

And the same for the box 2:

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

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

Alberto Deidda

I have solved in this way:

<!-- 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>

And the result is this image:

enter image description here

Thanks you all :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android layout: first element at the bottom, rest available below after scrolling

From Dev

Android Layout Below and Above

From Dev

Relative layout: layout_below a CenterVertical element

From Dev

Android Include at the bottom of layout

From Dev

layout below is getting focused in android

From Dev

How to include subfolder layout with <include/> tag android

From Dev

MvvMCross bind to <include> in android layout

From Dev

How to dynamically include a layout in Android?

From Dev

How to include a Layout Fragment in Android

From Dev

android:layout_below= Does Not Set TextViews Below ImageButtons

From Dev

android:layout_below not properly working

From Dev

Android: how to layout a fullscreen EditText, with a button below?

From Dev

How to break text below to another layout in Android

From Dev

Android: Relative layout content goes below screen

From Dev

How to start Drawer Layout below the toolbar in Android?

From Dev

how to set one linear layout below another linear layout in android

From Dev

Android place Relative Layout below Relative Layout programmatically

From Dev

Android place Relative Layout below Relative Layout programmatically

From Dev

how to set one linear layout below another linear layout in android

From Dev

How to add relative Layout below some element dynamically

From Dev

Select an Android xml layout element

From Dev

Android: How to use tools with include layout

From Java

How can I programmatically include layout in Android?

From Dev

Referring include layout in activity code android

From Dev

Replace `layout` of an <include/> tag programmatically for Android

From Dev

Second layout is not showing with include tag in android studio

From Dev

How can I programmatically include layout in Android?

From Dev

TableLayout, android:layout_weight, and include

From Dev

Android - how to access buttons inside include layout

Related Related

  1. 1

    Android layout: first element at the bottom, rest available below after scrolling

  2. 2

    Android Layout Below and Above

  3. 3

    Relative layout: layout_below a CenterVertical element

  4. 4

    Android Include at the bottom of layout

  5. 5

    layout below is getting focused in android

  6. 6

    How to include subfolder layout with <include/> tag android

  7. 7

    MvvMCross bind to <include> in android layout

  8. 8

    How to dynamically include a layout in Android?

  9. 9

    How to include a Layout Fragment in Android

  10. 10

    android:layout_below= Does Not Set TextViews Below ImageButtons

  11. 11

    android:layout_below not properly working

  12. 12

    Android: how to layout a fullscreen EditText, with a button below?

  13. 13

    How to break text below to another layout in Android

  14. 14

    Android: Relative layout content goes below screen

  15. 15

    How to start Drawer Layout below the toolbar in Android?

  16. 16

    how to set one linear layout below another linear layout in android

  17. 17

    Android place Relative Layout below Relative Layout programmatically

  18. 18

    Android place Relative Layout below Relative Layout programmatically

  19. 19

    how to set one linear layout below another linear layout in android

  20. 20

    How to add relative Layout below some element dynamically

  21. 21

    Select an Android xml layout element

  22. 22

    Android: How to use tools with include layout

  23. 23

    How can I programmatically include layout in Android?

  24. 24

    Referring include layout in activity code android

  25. 25

    Replace `layout` of an <include/> tag programmatically for Android

  26. 26

    Second layout is not showing with include tag in android studio

  27. 27

    How can I programmatically include layout in Android?

  28. 28

    TableLayout, android:layout_weight, and include

  29. 29

    Android - how to access buttons inside include layout

HotTag

Archive