または、ScrollViewをTableLayoutに組み込む必要がありますか?これも可能ですか?画面に任意の数の行を動的に作成したいのですが、行をスクロール可能にする必要があります。
私はこれをLinearLayoutを使用して機能させるのに無駄な努力をしてきましたが、TableLayoutまたはRelativeLayoutのいずれかに移行するときが来たと思います-どちらか一方の優先度についてコメントはありますか?
または、ScrollViewをTableLayoutに組み込む必要がありますか?これも可能ですか?画面に任意の数の行を動的に作成したいのですが、行をスクロール可能にする必要があります。
私はこれをLinearLayoutを使用して機能させるのに無駄な努力をしてきましたが、TableLayoutまたはRelativeLayoutのいずれかに移行するときが来たと思います-どちらか一方の優先度についてコメントはありますか?
スクロールレイアウト内でテーブルレイアウトを使用でき、それが可能です。例えば、
<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>
線形レイアウトの代わりにテーブルレイアウトを使用できます。
「リスト」スタイルのビューはいずれも、自動的にスクロールを実行しません。LinearLayout、TableLayout、RelativeLayout、それらのどれも(他の人が指摘したように)それらをScrollViewでラップするのはとても簡単で、それらが必要としない機能であるため、それを行いません。
以下のように、を指定する必要があり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>