Lesson 19 – Layout (TableLayout) in Kotlin Example
The Layout of type TableLayout groups components into rows and columns. A TableLayout contains a set of TableRow-like components that group visual components for each row (each row can have a different amount of visual components)
Have 9 buttons in the form of a TaTeTi board. Use one TableLayout, three TableRow and nine buttons.
First, create Project021 and go to the Layout tab, identify the component “TableLayout” and drag it into the visual interface, then drag three objects of type TableRow into the TableLayout:
After this we have the whole screen covered with a component of type “TableLayout”, now we have to start to arrange each of the buttons in each row.
The easiest way is to drag the buttons not to the design view but to the “Component Tree” window to the corresponding row:
We must drag each of the 9 buttons to the respective TableRow:
Another possibility given by this Layout is that a control expands more than one cell.
Arrange a fourth “TableRow” from the “Layouts” tab and add a button in the fourth row of the TableLayout:
Now select the button and load a 3 in the property “layout_span”:
We are sorry that this lesson was not useful for you!
Let us improve this lesson!
Tell us how we can improve this lesson?