3

他のビューと重ならずにフッターを画面の下部に固定できる場合にのみ、フッターを画面の下部に固定します。

問題は、ヘッダーまたはフッターに追加されるビューの数がわからないことです。

ウィンドウの下部にフッターを配置すると重なってしまう場合は、フッターをスクロールビューの下部に配置したいと考えています。(おそらく、最上位コンポーネントの下にある必要があるというルールで RelativeLayout に追加することでしょうか?)

ここに私が取得しようとしているものの写真があります:

望ましい結果

どこ:

1) RelativeLayout には、上部の TableLayout と下部の LinearLayout の両方が含まれます。

2) TableRows が追加されると、TableLayout は下方向に拡張されます。

3)ビューが追加されると、LinearLayout が下から上に拡張されます。

~~~

スクロールビューのサイズが大きくなり、コンポーネントが重ならないようにしたいと思います。

このような素晴らしいコミュニティサポートを前もって感謝します

4

1 に答える 1

10

線形レイアウトで解決できると思います。線形レイアウトで、ヘッダー、本文、フッターの 3 つのブロックを設定します。body を fill_parent および layout_weight=1 に設定します。このようにすると、body が拡張されて、ヘッダーとフッターが親から部分を取得した後に残った部分が埋めら​​れます。構造全体を ScrollView に配置します。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TableRow><TextView android:text="Text1"/></TableRow>
            <TableRow><TextView android:text="Text2"/></TableRow>
        </TableLayout>
        <RelativeLayout 
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TextView 
                android:text="@string/lorem_ipsum"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </RelativeLayout>
        <LinearLayout 
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="Text3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
            <TextView
                android:text="Text4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

Android 2.1 のエミュレーターでこれをテストしたところ、動作しているように見えます。

于 2011-08-20T19:52:49.477 に答える