要制作一个水平滚动的TableLayout,可以使用HorizontalScrollView来包裹TableLayout,并设置TableLayout的宽度为WRAP_CONTENT。具体步骤如下:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- 在这里添加TableLayout的内容 -->
</TableLayout>
</HorizontalScrollView>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableRow>
<TextView
android:text="Header 1"
android:padding="8dp" />
<TextView
android:text="Header 2"
android:padding="8dp" />
<!-- 添加更多表格单元格 -->
</TableRow>
<TableRow>
<TextView
android:text="Data 1"
android:padding="8dp" />
<TextView
android:text="Data 2"
android:padding="8dp" />
<!-- 添加更多表格单元格 -->
</TableRow>
<!-- 添加更多表格行 -->
</TableLayout>
这样就可以实现一个水平滚动的TableLayout。注意,如果表格内容过多,可能会导致水平滚动条出现,用户可以通过水平滚动来查看表格的全部内容。
腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云