下面是一个mainActivity代码滚动视图中使用Android的布局吹气
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_show);
tableLayout = (TableLayout) findViewById(R.id.tableLayout);
tableLayout.setVerticalScrollBarEnabled(true);
for (Integer j = 0; j < count; j++) {
//Rows will add till condition is true
}
}
XML文件:layout_show
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >It has eight headers for eight columns in it
</TableLayout>
XML要滚动table_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/table1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="2dp"
android:layout_alignParentRight="true"
android:background="@color/LightPink">---Columns defined here----
</TableRow>
一切工作正常
不同列的单行数据取自不同的来源。
在
table_item.xm
中使用ScrollView
l不起作用,但干扰了标题和项目列的对齐。
结果要实现的是:
- 保持头,但滚动
table_item.xml
希望我得到一些线索的充气行...
谢谢时间
我不明白这里有什么确切的问题。你能说清楚你的问题吗? – Vesko
感谢Vesko的回复..当for循环的次数超过12时,在12之后添加的其他行不能被看到,除非屏幕较大,所以需要向上滚动(垂直)。但我无法达到预期的效果。 –