这是我在线性布局下方显示表格布局的代码。这里我将滚动视图设置为内容视图。但只有表格布局显示在屏幕上。这里有任何布局问题。请帮助我,谢谢。
ScrollView scrollView = new ScrollView(this);
LinearLayout ll = new LinearLayout(getApplicationContext());
ll.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
Button btn1 = new Button(this);
btn1.setText("Button1");
ll.addView(btn1);
btn1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
TableLayout resultLayout = new TableLayout(this);
resultLayout.setStretchAllColumns(true);
resultLayout.setShrinkAllColumns(true);
这里尝试将线性布局放在表格布局上方,现在只显示线性布局
LinearLayout ll = new LinearLayout(getApplicationContext());
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
// Set the TextView for the Question
TextView tv1 = new TextView(getApplicationContext());
tv1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
tv1.setText("HI");
ll.addView(tv1);
ScrollView scrollView = new ScrollView(this);
TableLayout resultLayout = new TableLayout(this);
resultLayout.setStretchAllColumns(true);
resultLayout.setShrinkAllColumns(true);
//这里我有表格行代码
ll.addView(scrollView);
setContentView(ll);
现在根据您的答案将线性布局设置为内容视图滚动视图仅包含表格布局。但为什么它没有显示在屏幕上