0

滚动视图不工作。我尝试了不同的组合,但没有运气。有人能指出我哪里出错了吗?

    <?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:orientation="vertical"
    android:fillViewport="true" >

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#333333"
            android:orientation="horizontal" >

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:src="@drawable/ic_launcher" />

            <com.appsolute.ultimateproject.TypedfacedTextView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
                android:id="@+id/overview"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#ffffff"
                font:typeface="Roboto-Condensed.ttf" />
        </LinearLayout>

        <ListView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:paddingLeft="@dimen/list_padding"
            android:paddingRight="@dimen/list_padding" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#333333"
            android:orientation="horizontal"
            android:paddingTop="10dp" >

            <com.appsolute.ultimateproject.TypedfacedTextView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
                android:id="@+id/header"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"
                android:paddingBottom="2dp"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="#ffffff"
                font:typeface="Roboto-Condensed.ttf" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="10dp" >

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:src="@drawable/ic_action_person" />

            <com.appsolute.ultimateproject.TypedfacedTextView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
                android:id="@+id/header"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"
                android:textAppearance="?android:attr/textAppearanceSmall"
                font:typeface="Roboto-Condensed.ttf" />
        </LinearLayout>

        <View
            android:layout_width="wrap_content"
            android:layout_height="1dp"
            android:background="#333333"
            android:padding="1dp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="1dp" >

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:src="@drawable/ic_action_fav" />

            <com.appsolute.ultimateproject.TypedfacedTextView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
                android:id="@+id/favorites"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"

                android:textAppearance="?android:attr/textAppearanceSmall"
                font:typeface="Roboto-Condensed.ttf" />
        </LinearLayout>

        <View
            android:layout_width="wrap_content"
            android:layout_height="1dp"
            android:background="#333333"
            android:padding="1dp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="1dp" >

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:src="@drawable/ic_action_save" />

            <com.appsolute.ultimateproject.TypedfacedTextView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
                android:id="@+id/saved"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"
                android:textAppearance="?android:attr/textAppearanceSmall"
                font:typeface="Roboto-Condensed.ttf" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>

我使用了 fillViewport 并且还对底层内容进行了包装。请帮忙。

4

2 回答 2

1

'我怎样才能把ListView一个ScrollView'?问题和随后的答案,ListViews 处理自己的内部滚动,并且将一个滚动容器放入另一个滚动容器既昂贵(从布局性能的角度来看)又不可行。

解决此问题的最简单方法是使用ListView.addHeaderViewListView.addFooterView如果您希望布局中的其他项目随ListView.

于 2013-03-21T21:50:33.927 回答
0

NEVER put a ListView inside of a ScrollView! Google for "android ListView in Scrollview" for more information. One example would be this one: How can I put a ListView into a ScrollView without it collapsing?

于 2013-03-21T21:47:39.867 回答