In the following code, there are two tableLayouts with 3 columns each -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:stretchColumns="0,1">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test3"/>
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:stretchColumns="0,1"
android:shrinkColumns="2">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test3"/>
</TableRow>
</TableLayout>
</LinearLayout>
The first TableLayout has no mention of attribute for column2 and the second table layout has an explicit mention of attribute for column2 to be columnShrink. And both apparently give same output.
So, is it safe to assume that shrinkColumns is the default attribute even if not explicitly stated?
With that amount of text at the default font size I would expect the same output.
As the TableLayout Docs say
So if you don't specify and grow/shrinkable it will grow/shrink them all equally to match the parent.
But in you case TableLayout will because you have only one row, it first sizes them to basically
wrap_contentand finds that this does not match the parent width and therefore it will grow column 0 and 1 equally to fill the space.Because it is not short of space it (because it can grow) then it will never engage any shrink functionality because from the docs
The key word here is
extraYou would only expect it shrink a column if the text sized at
wrap_contentis wider than the screen (and therefore no column will be grown)So really
android:shrinkColumns="2"on table is redundant and has no affect, the default ofwrap_contentwill be usedBasically growing will never force any other column to shrink.