Putting Cells in Rows

 

Rows are declared by you, the developer, by putting widgets as children of a inside the overall . You, therefore, control directly how many rows appear in the table.

The number of columns is determined by Android; you control the number of columns in an indirect fashion.

There will be at least one column per widget in your longest row. So if you have three rows – one with two widgets, one with three widgets, and one with four widgets – there will be at least four columns.

However, a widget can take up more than one column if you include the property, indicating the number of columns the widget spans. This is akin to the attribute one finds in table cells in HTML:

 

 

In this XML layout fragment, the field spans three columns.

Ordinarily, widgets are put into the first available column. In the preceding fragment, the label would go in the first column (column 0, as columns are counted starting from 0), and the field would go into a spanned set of three columns (columns 1 through 3). However, you can put a widget into a different column via the property, specifying the 0‑based column the widget belongs to:

 

In this XML layout fragment, the Cancel button goes in the third column (column 2). The OK button then goes into the next available column, which is the fourth column.

 

Non‑Row Children of TableLayout

 

Normally, contains only elements as immediate children. However, it is possible to put other widgets in between rows. For those widgets, behaves a bit like with vertical orientation. The widgets automatically have their width set to , so they will fill the same space that the longest row does.

One pattern for this is to use a plain View as a divider (e.g., as a two‑pixel‑high blue bar across the width of the table).

 








Дата добавления: 2015-05-16; просмотров: 730;


Поиск по сайту:

При помощи поиска вы сможете найти нужную вам информацию.

Поделитесь с друзьями:

Если вам перенёс пользу информационный материал, или помог в учебе – поделитесь этим сайтом с друзьями и знакомыми.
helpiks.org - Хелпикс.Орг - 2014-2024 год. Материал сайта представляется для ознакомительного и учебного использования. | Поддержка
Генерация страницы за: 0.004 сек.