Measure column width in TableLayout
<p>I have a TableLayout with 4 columns. In order to stretch column 1 I do:</p>

<pre><code>android:stretchColumns="1"
</code></pre>

<p>This works well. Now I need to measure the width of this column 1 once it's displayed on the screen. I need to do this because I want to fit a custom view into this column. This custom view is just a rectangle which shall fill into the complete width of this column 1. I draw the rectangle by:</p>

<pre><code>public class TaskRectangleView extends View {
private ShapeDrawable mDrawable;
private Paint textPaint;    
private String task;

public TaskRectangleView(Context context, String task, int width, int height) {
    super(context);

    this.task = task;

    int x = 10;
    int y = 10;                

    mDrawable = new ShapeDrawable(new RectShape());
    int color = DbSettingsManager.getInstance(context).getColorByName(task);
    mDrawable.getPaint().setColor(color);
    mDrawable.setBounds(x, y, x + width, y + height); 

    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(10);        
}

protected void onDraw(Canvas canvas) {
    mDrawable.draw(canvas);

    canvas.drawText(this.task, 10, 20, textPaint);
}
</code></pre>

<p>}</p>

<p>So this custom drawn rectangle should fit into column 1 of my TableView. For this (so I believe) I need to measure the width of the column at display-time. How to do this? Thanks!</p>
