スクロール可能なTableLayoutを作成する方法は?質問する

スクロール可能な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"

しかし、それは役に立ちません。方法はあるでしょうか?

ベストアンサー1

全体を次のものに包みます:

<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>

おすすめ記事