Android:如何避免在listview中滚动标题,android?

Sri*_*vas 8 android listview header

我有一个列表视图,我将headerview添加到该列表.每件事情都很好,但是当滚动列表headerview也随着列表一起移动,所以我想避免headerview滚动,我的意思是我必须滚动列表当我列表到达topview(标题栏)时,headerview必须保持标题栏的底部.

任何人都可以为此提供解决方案吗?

kgi*_*kis 16

而不是标题使用以下布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <LinearLayout android:orientation="horizontal"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content">
      --> Your header layout here           
    </LinearLayout>

  <ListView android:id="@android:id/list"
      android:layout_width="fill_parent"
      android:layout_height="0dip"
      android:layout_weight="1" /> 
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

需要注意的重要事项:

  • ListView的id必须是@android:id/list为了能够使用ListActivity
  • 使用0高度并将权重设置为1

  • 一个问题是,如何将标题与其下划线数据对齐? (2认同)