设置TableRow的高度



TableRow有两种类型的内容。一条有两条线,另一条有。我希望每个人的身高都一样。我正在尝试这样的东西:

tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, 80));

还有其他想法吗?那么,我如何用dp变换"80"呢?

您可以通过设置填充来设置高度

    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        >

用于动态

tr.set填充(0,12,0,12);

您可以使用两种不同的行布局,并在代码中动态分配它们。在布局中定义高度。

我使用getViewTreeObserver解决此问题。您必须在tableLayout和重写onGlobalLayout上键入此方法。

在该方法中,您可以验证所有儿童的身高。然后你可以识别Max heigh。

最新更新