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 に答える