ここでは、線形レイアウトの下にテーブル レイアウトを表示するコードを示します。ここでは、スクロール ビューを contentview として設定していますが、画面に表示されるのはテーブル レイアウトのみです。
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);
回答スクロールビューに従ってコンテンツビューとして線形レイアウトを設定すると、テーブルレイアウトのみが含まれますが、なぜ画面に表示されないのですか