numberwang
numberwang

Reputation: 313

multiple layouts in one xml file

Is it possible to have more than one layout in an layout xml file?

I want something like below. I want this all in one fragment. The LinearLayout can't be a table row because its elements don't line up with the columns in the table. The table rows must be rows so their columns line up. I get an junk after document elements parsing error when trying to do this.

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageView
            ----
         />
        <ImageButton
            ----
         />

    <TableRow
        android:id="@+id/tablerow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageView
            ----
         />
        <ImageButton
            ----
         />

    </TableRow>

</TableLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp" >

    <ImageButton
        ----
     />

    <ImageButton
        ----
     />

    <ImageButton
        ----
     />

</LinearLayout>

Upvotes: 0

Views: 3681

Answers (2)

rupesh
rupesh

Reputation: 2891

So far i got from your question is that you want to show data in tabular format with (n) nos of rows. So you can use Table layout inside that use list view then implements array adapter or whatever you want to implement(Again it depends what kind of data you have.)

Upvotes: 0

Orphamiel
Orphamiel

Reputation: 884

Do it like this :

<LinearLayout>
    <TableLayout>
    </TableLayout>
    <LinearLayout>
    </LinearLayout>
</LinearLayout>

Upvotes: 4

Related Questions