设为首页 加入收藏

TOP

Android开发之ListView页眉页脚效果VS android背景渐变
2014-11-24 03:24:53 来源: 作者: 【 】 浏览:0
Tags:Android 开发 ListView 效果 android 背景 渐变

  大家都知道,在我们调用ListView的addFooterView()方法给List增加一个页脚时,如果列表内容很多,超过了屏幕大小,那么页脚就看不到了,可我们一般想要的效果是如下图所示的,在ListView的内容超过屏幕时,页脚还在屏幕的底部。


  实现上面的效果主要使用几个RelativeLayout标签和ListView组合即可,代码如下所示:


  < xml version="1.0" encoding="utf-8" >


  < RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"


  android:orientation="vertical" android:layout_width="fill_parent"


  android:layout_height="fill_parent">


  < RelativeLayout android:id="@+id/listHeader"


  android:background="@drawable/jbshape" android:layout_alignParentTop="true"


  android:gravity="center_horizontal" android:layout_width="fill_parent"


  android:layout_height="wrap_content">


  < TextView android:text="IdeasAndroid 列表演示" android:textColor="#000000"


  android:textSize="18dip" android:layout_width="wrap_content"


  android:layout_height="wrap_content">< /TextView>


  < /RelativeLayout>


  < RelativeLayout android:id="@+id/listFooter"


  android:background="@drawable/jbshape" android:gravity="center_horizontal"


  android:layout_alignParentBottom="true" android:layout_width="fill_parent"


  android:layout_height="wrap_content">


  < Button android:id="@+id/prePage" android:layout_width="wrap_content"


  android:layout_height="wrap_content" android:text="上一页"


  android:layout_alignParentLeft="true">< /Button>


  < Button android:layout_width="wrap_content"


  android:layout_gravity="right" android:layout_height="wrap_content"


android:text="下一页" android:layout_toRightOf="@id/prePage">< /Button>


  < /RelativeLayout>


  < ListView android:id="@+id/myListView" android:layout_width="fill_parent"


  android:layout_height="fill_parent" android:layout_below="@id/listHeader"


  android:layout_above="@id/listFooter">


  < /ListView>


  < /RelativeLayout>


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android:layout_weight 下一篇Android 滑动加载数据

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)
·Linux常用命令60条( (2025-12-25 00:50:40)
·nginx 监听一个端口 (2025-12-25 00:19:30)
·整个互联网就没有一 (2025-12-25 00:19:27)