Android 动态添加的表格行不显示

Android 动态添加的表格行不显示,android,tablelayout,tablerow,Android,Tablelayout,Tablerow,我得到了一个stings列表,我想添加尽可能多的TableRows,因为列表中有字符串。我在同一个项目的多个其他活动中都很好地完成了这项工作。所以我复制了代码,但它不起作用。桌子上的行没有显示出来。所以我注释掉了所有不必要的东西并进行了调试,所有代码都运行了,没有错误。但是表行仍然没有显示。。。有什么东西我忘了导入吗 进口: import java.util.ArrayList; import java.util.List; import android.R.color; import andr

我得到了一个stings列表,我想添加尽可能多的TableRows,因为列表中有字符串。我在同一个项目的多个其他活动中都很好地完成了这项工作。所以我复制了代码,但它不起作用。桌子上的行没有显示出来。所以我注释掉了所有不必要的东西并进行了调试,所有代码都运行了,没有错误。但是表行仍然没有显示。。。有什么东西我忘了导入吗

进口:

import java.util.ArrayList;
import java.util.List;
import android.R.color;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TableLayout.LayoutParams;
代码:

XML:

更新:


因此,在注释中提供了一些帮助之后,我注意到xml的主要LinearLayout包含height wrap_内容,因此我将其改为匹配父项。现在,如果我将静态表行添加到xml中,我会得到静态表行,但我尝试添加的动态表行仍然没有了。

转到“开发人员选项”并启用“显示布局边界”(show layoutbounds)——这通常会有所帮助——如果没有,请制作一个屏幕截图并发布到此处,谢谢您的提示。它不显示我试图添加的任何表行。我发布了xml,但正如我所说的,我在调试问题时删除了所有不必要的内容。在ScrollView上方有一些视图,您如何检查您的ScrollView是否实际位于屏幕边界?正如您所说,布局中还有其他视图。确保您的ScrollView没有超出屏幕范围。谢谢。它与ScrollView及其所有内容disapers类似。。我检查了布局,但它们都是静态高度,距离顶部不到一厘米。我仔细检查了ligi的提示,它们都在那里,没有一个延伸到屏幕底部。它只是xml显示的主要线性布局。
    TableLayout tl = (TableLayout) findViewById(R.id.MyTableLayout);

    for (int i =0; i< SomeList.size();i++){
        TableRow tr = new TableRow(this);
        TableLayout.LayoutParams p = new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.FILL_PARENT, 1.0f);
        tr.setLayoutParams(p);
        tr.setBackgroundColor(color.black);
        tl.addView(tr);
    }
<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TableLayout
        android:id="@+id/kategori_tl"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

    </TableLayout>

</ScrollView>