如何在我的 Android 应用中创建 'Table'

How to create a 'Table' in my Android app

所以我正在尝试在我的 Android 应用程序中创建一个 2 列 table,并且正在寻求有关实现它的最佳方法的建议。

此 table 将在每列上方有一个 header,并且 table 本身可能会超出屏幕底部。 (需要滚动)。 其中一列将填充文本。第二列充满了下拉微调器。

我尝试了多种不同的方式,但我不确定这样做的规范方式是什么...我应该使用相对布局吗?我应该将所有内容都包装在 ScrollView 中吗?我应该只使用 TableView 和 TableRows 吗?或者我应该使用其中多个的组合?

注意:我也希望能够在我的 table 中包含 "borders"。也许就在每一行的底部。我在某处读到只放置填满屏幕 width-wise 的 TextViews 并且具有类似 2dp 的高度和背景颜色集。这种方法是否适用于您的建议?

在此先感谢您的建议!

看来是船长的工作ListView!您可以 addHeader 滚动或将其包装在 RelativeLayout 中并固定 header。您可以在自动创建的行之间设置分隔符。您的行将由适配器生成。这是行布局应该的样子

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Spinner
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>
</LinearLayout>