jmendegan jmendegan - 23 days ago 7
Java Question

Is it possible to add more than one TableLayout in a LinearLayout with a ScrollView in Android development?

I have this nice android app made up and was going to add in some finishing touches, one of which includes a page with two tables, and found that I can't make it happen. Basically I am trying to make a table with some values (across 4 or 5 columns) and then make another table below of different values (with only 2 columns). The tables will exceed the screen so it needs a ScrollView. However when I put all this together I get an error: ScrollView can host only one direct child. I have tried putting it in a LinearLayout. That does nothing either. I

Answer

yes you can use more TableLayout but you need only one parent layout in the scrollview

<Scrollview>
      <LinearLayout> //parent layout
          <TableLayout>
           <TableRow></TableRow>
            </TableLayout>
           <TableLayout>
          <TableLayout>
         </TableLayout>
        </TableLayout>
     <LinearLayout>
<Scrollview>