Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does android:layout_column do?

Am learning android and am struggling to get my head around this particular layout attribute, reading the google dev docs it says:

android:layout_column

The index of the column in which this child should be. Must be an integer value, such as "100". This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type. This corresponds to the global attribute resource symbol layout_column.

Can anyone explain how this maps to an html equivalent (as table rows appear to borrow heavily from them)?

Is it the number of columns it take sup - eg colspan?

like image 859
Alphatester77 Avatar asked Dec 04 '10 23:12

Alphatester77


People also ask

What is table layout used for?

A layout that arranges its children into rows and columns. A TableLayout consists of a number of TableRow objects, each defining a row (actually, you can have other children, which will be explained below). TableLayout containers do not display border lines for their rows, columns, or cells.

What is table layout explain with example?

Android TableLayout going to be arranged groups of views into rows and columns. You will use the <TableRow> element to build a row in the table. Each row has zero or more cells; each cell can hold one View object. TableLayout containers do not display border lines for their rows, columns, or cells.

What is a table layout in Android?

TableLayout is a ViewGroup that displays child View elements in rows and columns. Note: For better performance and tooling support, you should instead build your layout with ConstraintLayout. TableLayout positions its children into rows and columns.

What is grid layout Android?

android.widget.GridLayout. A layout that places its children in a rectangular grid. The grid is composed of a set of infinitely thin lines that separate the viewing area into cells. Throughout the API, grid lines are referenced by grid indices.


1 Answers

Uh, it means "the index of the column in which this child should be". The only tricky part is that columns start at 0.

For example:

<?xml version="1.0" encoding="utf-8"?> <TableLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:stretchColumns="1">     <TableRow>         <TextView                 android:text="URL:" />         <EditText android:id="@+id/entry"             android:layout_span="3"/>     </TableRow>     <TableRow>         <Button android:id="@+id/cancel"             android:layout_column="2"             android:text="Cancel" />         <Button android:id="@+id/ok"             android:text="OK" />     </TableRow> </TableLayout> 

Both rows in the above layout have four columns. The first one has four columns because it has a TextView in column 0 and an EditText spanning columns 1, 2, and 3. The second one has four columns because it skips columns 0 and 1 and puts the two Button widgets in columns 2 and 3, courtesy of the android:layout_column="2" attribute in the first Button.

like image 52
CommonsWare Avatar answered Oct 05 '22 04:10

CommonsWare