这不是一个好主意,使用两个滚动视图。但是,如果需要的话,你可以做一两件事:
创建XML布局:
android:id="@+id/scrollview_vertical_table"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:ignore="UselessParent" >
android:id="@+id/tablelayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:stretchColumns="*" >
而在这个表中插入记录或行编程为:
TableLayout tableLayoutTransactionLineHeading = (TableLayout) findViewById(R.id.tablelayout);
for(int j=0; j
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
TextView lineno = new TextView(this);
lineno.setText(lineNo[j]);
lineno.setPadding(10, 10, 10, 10);
lineno.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
tableRow.addView(lineno);
View v = new View(this);
v.setLayoutParams(new TableRow.LayoutParams(1, TableRow.LayoutParams.MATCH_PARENT));
v.setBackgroundColor(Color.rgb(50, 50, 50));
tableRow.addView(v);
tableLayout.addView(tableRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT,0f));
}
希望这将帮助你。