title: Android TableLayout in a ListView, mysterious column shrinking
body: <p>I am using TableLayout within a ListView. The data I'm presenting is tabular in nature and the TableLayout seems like a good way to ensure that the columns line up as desired. This approach worked well most of the time - see below.</p>
  
  <p>Desired view:<br>
  <a href="https://i.stack.imgur.com/qRTiM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qRTiM.png" alt="desired view"></a></p>
  
  <p>But occasionally the Views representing the columns wrapped their text content as shown below.</p>
  
  <p><a href="https://i.stack.imgur.com/qRTiM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DEw8Z.png" alt=""></a></p>
  
  <p>After searching around for a while, I came across the <a href="http://code.google.com/p/android/issues/detail?id=4000" rel="nofollow noreferrer">following discussion on the Android Google Group</a>. In response, I set <code>android:stretchColumns="*"</code> in the TableLayout and voila, the contained TextViews stopped mysteriously wrapping their text.</p>
  
  <p>Here's a partial content of the layout's XML, with the change highlighted with a comment:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:stretchColumns="*"&gt;  &lt;!-- stretchColumns needed to prevent
                TableLayout from unilaterally deciding to shrink the column
                width and thereby causing text to wrap. --&gt;
  </code></pre>
  
  <p>While I'm now getting the desired result, I'm a bit confused as to why this "fixed" my problem. The <a href="http://developer.android.com/reference/android/widget/TableLayout.html" rel="nofollow noreferrer">TableLayout documentation</a> states that "The width of a column is defined by the row with the widest cell in that column." But if that's true, why did the columns apparently shrink in size in the first place causing the text to wrap?</p>
  
  <p>Does anyone have a good explanation?</p>