androidandroid-tablelayoutstretchshrink

How do android:shrinkColumns and android:stretchColumns work?


I can set android:shrinkColumns and android:stretchColumns at TableLayout.

For example:

<TableLayout
    android:shrinkColumns="2,3"
    android:stretchColumns="1,3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

So how do this properties affects columns?


Solution

  • TableLayout can specify certain columns as shrinkable or stretchable by calling setColumnShrinkable()(xml:android:shrinkColumns) or setColumnStretchable()(xml:android:stretchColumns).

    If marked as shrinkable, the column width can be shrunk to fit the table into its parent object. If marked as stretchable, it can expand in width to fit any extra space.

    The total width of the table is defined by its parent container. It is important to remember that a column can be both shrinkable and stretchable .

    For details information you may visit

    https://developer.android.com/reference/android/widget/TableLayout.html