Alignment issue while implementing TableRow
<p>I need to accomodate three columns in a TableLayout.</p>

<p>The following code creates the table row headers &amp; then populates the values in the columns. Table layout has been defined in the layout xml.</p>

<pre><code>TableLayout tableLay = (TableLayout) findViewById(R.id.table);

// Table Headers
TextView firstNameHeader = new TextView(this);
firstNameHeader.setGravity(Gravity.CENTER);
TextView lastNameHeader = new TextView(this);
lastNameHeader.setGravity(Gravity.CENTER);
TextView ageHeader = new TextView(this);
ageHeader.setGravity(Gravity.CENTER);


// Adding the Table headers to Table Row  
TableRow empHeaderTableRow = new TableRow(this);
empDetailsTableRow.addView(firstNameHeader);
empDetailsTableRow.addView(lastNameHeader);
empDetailsTableRow.addView(ageHeader);

// Adding the Table Row to Table Layout
tableLay.addView(empDetailsTableRow);

// Adding Column Data

for(int count = 0; count &lt; empDetails.size ; count++){
TextView firstNameData = new TextView(this);
firstNameData.setGravity(Gravity.CENTER);
firstNameData.setText(...);
TextView lastNameData = new TextView(this);
lastNameData.setGravity(Gravity.CENTER);
lastNameData.setText(...);
TextView ageData = new TextView(this);
ageData.setText(...);
ageData.setGravity(Gravity.CENTER);

TableRow empDataTableRow = new TableRow(this);
empDataTableRow.addView(firstNameData);
empDataTableRow.addView(lastNameData);
empDataTableRow.addView(ageData);
}

// Adding the Table Row to Table Layout
tableLay.addView(empDataTableRow);
</code></pre>

<p>There is alignment issue with the above code.
When any of the data like first name , last name exceeds a certain length , the entire colum shifts out of the screen. In that case , only one column is visible on the screen while the rest of the columns goes beyond the screen.</p>

<p>I want to set fixed column width for the three columns  , so that if any data wrt to a particular column exceeds length, it will get truncated or displayed on the second line &amp; the other column positions (aligned) is not disturbed.</p>

<p>Do I need to truncate the text if it exceeds the column width or it can be done automatically with the help of any method already available in TextView.</p>

<p>Any hints/suggestions welcome.</p>
