2

androidレイアウトxmlファイルに<.ImageView> enter code heres(icons)があり、これは。で囲まれてい<ScrollView>ます。

例えば。

<.ScrollView><br>
<.LinearLayout><br>
<.ImageView> ...<./ImageView><br>
<./LinearLayout><br>
<./ScrollView>

このレイアウトに、固定フッターを付けたいと思います。基本的に、画面の下部にある小さなタブは、一番下または一番上までスクロールしても表示されたままになります。

4

3 に答える 3

5

LinearLayout私はこのようなレイアウトをルート要素として作成し、子に重みを付けて画面のプロパティを動的に割り当てる傾向があります。レイアウト定義をコンパクトに保ち、追加のIDを定義する必要がありません。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp" 
        android:layout_weight="1" >

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

            <ImageView ... />
            <ImageView ... />
            ...
            <ImageView ... />

        </LinearLayout>
    </ScrollView>

    <!-- footer here -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        ...
    </LinearLayout>
</LinearLayout>

RelativeLayoutただし、ルート要素としてScrollView、下に配置されたフッターの「上」に配置されたものを使用すると、パフォーマンスの点でおそらくわずかに優れていますが、このような単純なビュー階層の場合に目立った違いが生じるとは思えません。RelativeLayoutアプローチでは、いくつかのIDを割り当てる必要があります(少なくともフッターに)。

于 2012-04-11T07:50:21.653 に答える
1

このようなもの..

<.ScrollView>
<.LinearLayout>
<.ImageView> ...<./ImageView>
<./LinearLayout>
<./ScrollView>
<LinearLayout>
<-- your footer here -->
</LinearLayout>
于 2012-04-11T05:45:31.610 に答える
0

Uもこのように試すことができます。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView14"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />
            <ImageView
                android:id="@+id/imageView11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />
            <ImageView
                android:id="@+id/imageView12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

        </LinearLayout>
    </ScrollView>

    <RelativeLayout
        android:id="@+id/relativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/blackbg"
        android:layout_alignParentBottom="true" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="Button" />

    </RelativeLayout>

</RelativeLayout>
于 2012-04-11T05:58:43.953 に答える