android - 如何制作可滚动的 TableLayout?

标签 android scroll android-tablelayout

请看这里的 XML 代码:

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TableRow
    android:id="@+id/tableRow1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <!-- Some stuff goes here -->

    />
    </TableRow>

    <TableRow
    android:id="@+id/tableRow2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <!-- Some stuff goes here -->

    />
    </TableRow>

    <TableRow
    android:id="@+id/tableRow3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <!-- Some stuff goes here -->

    />
    </TableRow>


</TableLayout>

我的代码比这长得多,但我只是删除了不必要的部分。 问题是我想让这个 TableLayout 可以滚动,这样我的所有东西都可以显示出来。

我试图将这一行放在 TableLayout 中以使其可滚动:

android:isScrollContainer="true"

但它不能完成这项工作。 有什么办法吗?

最佳答案

把整个东西包起来:

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="none"
    android:layout_weight="1">
    <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical">

    ...

</ScrollView>

关于android - 如何制作可滚动的 TableLayout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6513718/

相关文章:

java - 检查 Intent 调用特定 Component 是否可调用?

javascript - 如果滚动位于 JavaScript 顶部,如何将类添加到导航栏

css 滚动捕捉不适用于 React 应用程序中的 div

android - findViewWithTag 在 TableLayout 中返回 null

android - 如何在表格布局中动态创建列?

java - 将 float 转换为字符串时避免舍入数字

android - 在 Android 中集成 Admob

android - 具有两行并右对齐的 Android 表格布局问题

java - 在 Java 和 XML 中使用自定义布局

javascript - 在 MVC3 中使用 Javascript 垂直滚动 div