ScrollView内にいくつかのボタンを含む1つの列のテーブルがあります。私の目標は、列の上部にヘッダーを追加して、下にスクロールしてもヘッダーが表示されるようにすることです。
私はこのテーマについていくつかの調査を行い、「ダミー」の行などを試しましたが、それを機能させる方法がわかりません。
これが私がこれまでに試したことですが、スクロールしてもヘッダーは移動しません。前もって感謝します。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation='horizontal' >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="200dp" >
<TableLayout android:id="@+id/table_left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left" >
<TableLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow>
<TextView android:id="@+id/header_tab1"
android:textColor="@android:color/black"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Header_tb1" >
</TextView>
</TableRow>
</TableLayout>
<TableRow>
<TextView
android:layout_height="0dp"
android:layout_weight="1"
android:text="Header_tb1" >
</TextView>
</TableRow>
<TableRow android:id="@+id/row_1_tb1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/Button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Button1"
android:textSize="23sp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_2_tb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Button2"
android:textSize="23sp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_3_tb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Button3"
android:textSize="23sp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_4_tb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Button4"
android:textSize="23sp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_5_tb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Button5"
android:textSize="23sp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row6_tb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Button6"
android:textSize="23sp" >
</Button>
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>