0

还是我必须将 ScrollView 合并到 TableLayout 中?这甚至可能吗?我想为屏幕动态创建任意数量的行,但需要这些行是可滚动的。

我一直在徒劳地尝试让这个使用 LinearLayout 工作太久了,我认为是时候转移到 TableLayout 或 RelativeLayout 了——对一个比另一个更可取的任何评论?

4

3 回答 3

4

您可以在滚动布局中使用表格布局,那么这是可能的。例如,

<ScrollView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical" >

            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >
</LinearLayout>

</ScrollView>

您可以使用表格布局而不是线性布局..

于 2012-03-13T03:59:28.983 回答
2

“列表”样式的视图都不会自动滚动。LinearLayout、TableLayout、RelativeLayout,它们都没有这样做,因为(就像其他人指出的那样)将它们包装在 ScrollView 中非常容易,这只是它们不需要的功能。

于 2012-03-13T06:09:49.187 回答
1

ScrollView您必须为您指定一个,TableLayout如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:background="#ffffff"
    android:layout_height="fill_parent">

    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff">

        <TableLayout 
            android:id="@+id/myTableLayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:shrinkColumns="1"/>     

    </RelativeLayout>

</ScrollView>
于 2012-03-13T04:02:03.257 回答