Layout_below element inside included layout

I am trying to figure out a way to align an element in a layout with an element inside the included layout.

Here is a visual representation: enter image description here

And here is an example of the code I'm looking for (which is obviously not working):
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> 

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> 



I guess the best way to achieve this is to dynamically position the dark gray box in the code, but I don't know where to start. Any help would be awesome.

+8
android android-layout relativelayout
source share
1 answer

Can you do this below your inclusion? Something like this (use information instead of 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> 
+7
source share

All Articles