5

コンテンツ

中央部分をスクロール可能にしたい。私は何のアイデアも得ることができませんでした..これは私のxmlアウトラインです。この xml アウトラインをスクロール可能な領域に挿入したいと考えています。

注: ヘッダーとフッターは一定である必要があります。中央の領域のみスクロールする必要があります

概要

4

3 に答える 3

10

より簡単な方法は、以下を使用することです。

<RelativeLayout 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"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/headerView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >
    </LinearLayout>

    <ScrollView
        android:id="@+id/scrollablContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/footerView"
        android:layout_below="@+id/headerView" >

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:id="@+id/footerView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
    </LinearLayout>

</RelativeLayout>
于 2012-12-18T17:17:34.903 に答える
3

ヘッダーとフッターを含む listView が必要になる場合があります。

これを見たことがありますか?

こちらもご覧ください

そしてこれも。

これがすべてあなたを助けることを願っています。そうでない場合は、私に知らせてください。

コーディングをお楽しみください。:)

于 2012-12-19T03:38:19.460 に答える
3

外部コンテナーを LinearLayout から RelativeLayout に置き換え、ヘッダー ImageView に alignParentTop=true を設定し、フッター ImageView に alignParentBottom=true を設定し、layout_above="@+id/imageViewFooter"、layout_below="@+id/ を設定する必要があります。 ScrollView の imageViewHeader"。このような:

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

    <ImageView
        android:id="@+id/imageViewHeader"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="false"
        android:layout_alignParentTop="false"
        android:scaleType="fitXY"
        android:src="@drawable/square" />

    <ImageView
        android:id="@+id/imageViewFooter"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"

        android:scaleType="fitXY"
        android:src="@drawable/square" />

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/imageViewFooter"

        android:layout_below="@+id/imageViewHeader" >

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

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

            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />

            <Button
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />

            <Button
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
        </LinearLayout>
    </ScrollView>

</RelativeLayout>
于 2012-12-18T17:31:48.113 に答える