Search code examples
androidtablelayoutandroid-tablelayout

How can I create a layout that spans multiple rows using Android TableLayout?


How would I go about creating the following layout using tablelayout? Column spanning is straightforward, but I haven't found any clear guidance on row spanning.

enter image description here


Solution

  • You cannot do this directly, but will have to use nested layouts instead. In your case, using nested TableLayouts will be very inefficient though, so you should use a combination of other layouts.

    Try something like:

    LinearLayout with vertical orientation (1)
      LinearLayout with a horizontal orientation (2)
        Box like view + LinearLayout with vertical orientation (3)
                          Row 1
                          LinearLayout with horizontal orientation (4)
                            The Two Views
                          Row 3
      Your other large view
      Your other other large View
    

    Here's a color coded version of your layout (each color is a new parent Layout)

    enter image description here