1

タブ内にネストされた TableLayout をスクロールしようとしています。意図したとおりにテーブルをスクロールできますが、問題は、テーブルが上にスクロールすると、スクロールするとタブの後ろに表示されることです。

スクロールするレイアウトのテーブル部分だけを作成したい。

最後に、テーブル内の行の形式で動的に表示する情報の凡例 (キー ガイド) として機能する RelativeLayout があります。そのため、画面の下部にある必要があり、テーブル自体のようにスクロールしないでください。ただし、このコードでは、タブの下のすべてが上にスクロールします (RelativeLayout を除く)。

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

//Fixed On Screen

<TabHost
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
        </TabWidget>

//Fixed On Screen

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingTop="4dp" >

            <TableRow
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="fill_horizontal"
                android:padding="4dp" >

                <TextView
                    style="@android:style/TextAppearance.Medium"
                    android:layout_weight="1"
                    android:text="@string/start"
                    android:textStyle="bold"
                    android:typeface="serif" />

                <TextView
                    style="@android:style/TextAppearance.Medium"
                    android:layout_weight="1"
                    android:text="@string/end"
                    android:textStyle="bold"
                    android:typeface="serif" />

                <TextView
                    style="@android:style/TextAppearance.Medium"
                    android:layout_weight="1"
                    android:paddingLeft="5dp"
                    android:text="@string/effect"
                    android:textStyle="bold"
                    android:typeface="serif" />
            </TableRow>
        </TableLayout>
    </LinearLayout>

//Scroll this content inside the Tab ONLY

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center_horizontal" >

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <TableLayout
                    android:id="@+id/Tab1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:paddingTop="4dp"
                    android:stretchColumns="*" >
                </TableLayout>

                <TableLayout
                    android:id="@+id/Tab2"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:paddingTop="4dp"
                    android:stretchColumns="*" >
                </TableLayout>
            </LinearLayout>
        </ScrollView>
    </FrameLayout>
</TabHost>

//Fixed On Screen at the very bottom so the area between this and Tab is what scrolls

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_weight="1"
            android:background="@color/green"
            android:padding="5dp"
            android:text="@string/excellent"
            android:textColor="#FFFFFF" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_weight="1"
            android:background="@color/light_blue"
            android:padding="5dp"
            android:text="Good"
            android:textColor="#FFFFFF" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_weight="1"
            android:background="@color/dark_gray"
            android:padding="5dp"
            android:text="@string/normal"
            android:textColor="#FFFFFF" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_weight="1"
            android:background="@color/red"
            android:padding="5dp"
            android:text="Bad"
            android:textColor="#FFFFFF" />
    </TableRow>
</RelativeLayout>

要するに、画面上で次のことを修正したい:

  • タブ
  • 最初の TableLayout
  • 最後の RelativeLayout

そして、真ん中の FrameLayout/TableLayout だけをスクロールしたい。このレイアウトは行で動的に埋められます。

wrap_contentたぶん、または多分と同じくらい単純だと感じていfill_parentます。しかし、これを理解することはできないようです。

ありがとう!

4

0 に答える 0