原文链接:http://marshal.easymorse.com/archives/3024
要实现类似IMBd类似的布局。
可以看出它的列表上方的图片展示区和下面列表条目是一体的,在上下滚动的时候。而图片展示区不是列表条目。
当然可以分别实现,图片展示区用Gallery,下面用ListView,但是如果横屏,则ListView部分的高度将很短,不方便上下滚动选择。也可以强制竖屏,不过这样用户体验会变差。
其实ListView提供了Header,IMBd实现的图片展示区就是自定义的ListView Header。
写个简单的例子说明这个事情。先写个最简单的。
这里的header就是一个TextView生成的ListView Header部分。在布局的Listview部分:
在代码中在ListView中加入Header:
1
2
3
4
|
listView = (ListView) this.findViewById(R.id.list);
TextView textView = new TextView(this);
textView.setText("header");
listView.addHeaderView(textView);
|
源代码见:
Header部分是可以添加多个的,比如:
对Header再做进一步定制。见效果:
这里的Header部分使用了自定义视图。
首先要增加一个小房子的图:
然后,创建一个针对Header的layout:
该文件内容:
然后在代码中通过inflate的方式把layout加入到header。
1
2
|
listView.addHeaderView(LayoutInflater.from(this).inflate(
R.layout.table_title, null));
|
分享到:
相关推荐
Android-Pinned-Header-Listview 这个库是在找到的。
Android应用源码开发Demo,主要用于毕业设计学习。
Android高级应用源码-仿网易新闻listview加header图片滚动,上拉下拉刷新.zip
Easy to use ListView with pinned sections for Android 2.1 and higher. Pinned section is a header view which sticks to the top of the list until at least one item of that section is visible. ...
练习过程中拆分listView各个东西,然后拼凑上去,初学者可以看看。
This is a very simple library for Android that allows you to stick an header to a ListView and easily apply animation to it Usage To use the StikkyHeader library, you just need 3 lines: ...
良好的设计,如果你想定制自己的UI样式,非常简单,就像给ListView加一个Header View那么简单。 支持 API LEVEL >= 8。 支持所有的View: ListView, GridView, ScrollView, FrameLayout, 甚至 TextView. ------------...
Android中ListView的简单使用,BaseAdapter的简单使用,ListView添加表头headView表尾bootView
仿网易新闻listview加header图片滑动、上拉下拉刷新的小demo,项目是android studio的
fat-listview Overview fat-listview是对ListView的扩展。主要实现下面的功能: 下拉刷新功能 上拉加载更多功能 类似iOS UITableView的Section Header功能 代码并非原创,多数代码来自: ...开发工具:Android Studio
点击header展开listview,再次点击收起listview,过程采用android原生动画实现。
安卓Android源码——仿网易新闻listview加header图片滚动,上拉下拉刷新.zip
Android-PullToRefreshRecyclerView This is a project based on RecyclerView with pull-to-refresh feature. It support addding Header, auto-loading more data when scrolling to bottom. It can help you to ...
源码参考,欢迎下载
If you are looking for a listview with a paged header this is the dependency you are looking for. With PagedHeadListView you will be able to set your own fragments as new pages for the header, and a ...
Anroid ListView分组和悬浮Header以及下拉刷新功能实现 http://blog.csdn.net/nwsuafer/article/details/42423573
•android代码优化—-ListView中自定义adapter的封装(ListView的模板写法) 以后每写一个ListView,就这么做:直接导入ViewHolder.java和ListViewAdapter,然后写一个自定义adapter继承自ListViewAdapter就行了。 ...
仿网易新闻listview加header图片滚动,上拉下拉刷新,分不多效果不错!
仿网易新闻listview加header图片滚动,上拉下拉刷新.zip项目安卓应用源码下载仿网易新闻listview加header图片滚动,上拉下拉刷新.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3....