Подтвердить что ты не робот

Как сделать прокручиваемый 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"

Но он НЕ выполняет эту работу. Есть ли способ?

4b9b3361

Ответ 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>

Ответ 2

Технически не требуется LinearLayout в ScrollView:

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

    <TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    android:isScrollContainer="true">

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

        <--!Everything Else You Already Have-->

    </TableRow>
 </TableLayout>
</ScrollView>

Как только вы заберете достаточное количество места в ScrollView, эффект прокрутки активируется (вроде HTML TextArea, как только у вас будет достаточно строк текста, прокрутка активируется.)

Вы также можете вложить ScrollView, но снова вы не сможете почувствовать эффект прокрутки, пока не получите достаточно содержимого в ScrollView.

Ответ 3

спасибо mbauer, он решил мою проблему i место в порядке

  • TableLayout
  • TableRow с концом (для заголовка столбцов)
  • ScrollView
  • LinearLayout
  • x TableRow с концом
  • end LinearLayout
  • конец ScrollView
  • end TableLayout