tags:

views:

30

answers:

1

Hi!
This is an android development question.
If I first set the content view to my xml layout using setContentView(R.layout.main); and then add another content view using addContentView(layout, params), the content views overlap each other. I want the second content view to position itself directly under the first one. Is it possible or do I need to combine the xml and the programatically created layouts in some way? Both of the layouts are linear.

Thanks in advance

+2  A: 

Put both Layouts inside an LinearLayout with vertical orientation. thats it.

Edit:

what i mean is you have to create a 3 layout xml files.

  1. Main.xml
  2. layout1.xml --> your first layout
  3. layout2.xml --> your second layout

your main layout file shoul be like this:

<LinearLayout android:orientation="vertical">
<include android:id="+id/lay1" android:layout="@layout/layout1"/>
<include android:id="+id/lay2" android:layout="@layout/layout2"/>
</LinearLayout>

Now your the main layout to your setContentView(R.layout.main)

Praveen Chandrasekaran
sorry for troubling you, but how do I convert an xml layout to a LinearLayout then?
Mountain King
@Mountain King: you have to use `include` tag. i have made a edit in my post. check out.
Praveen Chandrasekaran