Android:如何避免标题在列表视图中滚动,android? [英] Android : How to avoid header from scrolling in listview , android?

查看:33
本文介绍了Android:如何避免标题在列表视图中滚动,android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a list view , where i am adding headerview to that list . every thing fine , but when am scrolling list headerview also moving with list, so i want to avoid headerview scrolling , i mean i have to scroll only list when i list reached to topview (titlebar), headerview has to remain bottom of titlebar .

谁能给个解决办法?

推荐答案

使用以下布局代替标题:

Instead of a header use the following layout:

<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>

需要注意的重要事项:

  • ListView 的 id 必须是 @android:id/list 才能使用 ListActivity
  • 使用 0 高度并将权重设置为 1
  • The id of the ListView must be @android:id/list in order to be able to use a ListActivity
  • Use a 0 height and set the weight to 1

这篇关于Android:如何避免标题在列表视图中滚动,android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆