3

我有一个包含五列和多行动态内容的表格布局。

我们注意到,每一列都取该列所有单元格的最大值的宽度。

我不想水平滚动,但我想检测何时超过总宽度,以便删除其中一列。

这可能吗?

4

2 回答 2

1

您可以自己在 TableLayout 上调用 measure() 并使用 getMeasuredWidth/Height 检查结果。

于 2011-07-25T09:31:54.577 回答
0

如果您在循环中添加每一行,那么我想您可以执行以下操作:

int longestRowWidth = 0;

for(i=0; i<6; i++) 
{

    // Add your row here

    // Get the width of your new row here
    int rowWidth = blablah


    // Check if it exceeds longestRowWidth
    if(rowWidth > longestRowWidth)
    {
        // Do your stuff here.
    }
}
于 2011-07-25T08:55:22.527 回答