Reputation: 31
I am not sure how to nest different layouts. i want to have one listlayout and one table layout side by side. I want ListLayout on left and Table layout on right of listlayout for example
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:focusable="true"
android:focusableInTouchMode="true" />
And One tablelayout
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
<TableRow>
<TextView
android:layout_column="1"
android:text="Open..."
android:padding="3dip" />
<TextView
android:text="Ctrl-O"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:layout_column="1"
android:text="Save..."
android:padding="3dip" />
<TextView
android:text="Ctrl-S"
android:gravity="right"
android:padding="3dip" />
</TableRow>
</TableLayout>
But if i do it like this then i don't get listlayout and table layout is on the left. I am just a beginner and may be i am doing it completely wrong. can anyone guide me please its urgent....
Upvotes: 2
Views: 3400
Reputation: 5097
Have you tried putting the table and list layout in a LinearLayout?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<!-- List view goes here -->
<!-- Table layout goes here -->
</LinearLayout>
There is also the RelativeLayout, which lets you specify where sublayouts are positioned relative to other sublayouts. For example: https://web.archive.org/web/20210117112714/http://www.tutorialforandroid.com/2009/01/relativelayout-in-android-xml.html
Upvotes: 1
Reputation: 5985
If you used Relative layout then use following parameters for Table and List Views in xml file. For ListView-->android:layout_alignParentLeft="true" and for TableView,-->android:layout_toRightOf="ListView" Also if this doesn't work,add one more android:layout_alignParentRight="true" for tableView
Upvotes: 0
Reputation: 1003
You need to have one overall layout, and then put sub-layouts inside of it. One way to do what you want is to have the top level layout a LinearLayout with horizontal orientation. One thing to keep in mind, performance goes down a little as you add more and more layouts, so it is a good idea to try to minimize the number of layouts.
Upvotes: 1
Reputation: 7356
You could start with a ScrollView or a TableLayout as the top parent. If it's a TableLayout, then you'll need a TableRow.
<TableLayout>
<TableRow>
{Add your ListView Here}
{Add your nested TableLayout here}
</TableRow>
</TableLayout>
Since there is no TableColumn or TableCell, it should treat each child in the TableRow as a column.
Upvotes: 1