【发布时间】:2015-01-04 12:12:31
【问题描述】:
我想在列表视图的顶部添加一个视图操作(我们称之为标题)。当用户向下滚动时,我希望所有内容都向上移动(包括标题)。然而,现在当用户滚动时,标题保持固定在顶部(如 CSS 上的“位置:固定”),而不是与其余内容一起滚动。
如何让用户滚动所有内容而不仅仅是 ListView 的内容?
这就是我现在的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?attr/color2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/header"
style="@style/header"
android:drawableLeft="@drawable/ic_setup"
android:text="@string/fragment_contacts"/>
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
android:fastScrollEnabled="false">
</ListView>
</LinearLayout>
【问题讨论】: