RecyclerView介绍(一)----简单概述
来源:互联网 发布:php的进程是什么 编辑:程序博客网 时间:2024/05/18 02:45
最近时间有时间,正好研究研究RecyclerView 一看 才发现确实很强大 下面 就逐一介绍 最近的成果。先从API看起 对RecyclerView的介绍如下
A Recycler is responsible for managing scrapped or detached item views for reuse.
A “scrapped” view is a view that is still attached to its parent RecyclerView but that has been marked for removal or reuse.
Typical use of a Recycler by a RecyclerView.LayoutManager will be to obtain views for an adapter’s data set representing the data at a given position or item ID. If the view to be reused is considered “dirty” the adapter will be asked to rebind it. If not, the view can be quickly reused by the LayoutManager with no further work. Clean views that have not requested layout may be repositioned by a LayoutManager without remeasurement.
以上英文看不懂没关系 我简单说说我个人的理解 Recycler 顾名思义 回收者的意思 这也是RecyclerView的精髓所在 google之所以推出RecyclerView就是进一步对常用控件进行优化,而RecyclerView重点关注的是如何回收和复用View。就像上文说的,如果不是“dirty”的view那么 会通过LayoutManager快速的复用。
说到这 我们必须介绍一下LayoutManager了 我们先看一下官方的介绍:
A LayoutManager is responsible for measuring and positioning item views within a RecyclerView as well as determining the policy for when to recycle item views that are no longer visible to the user. By changing the LayoutManager a RecyclerView can be used to implement a standard vertically scrolling list, a uniform grid, staggered grids, horizontally scrolling collections and more. Several stock layout managers are provided for general use.
If the LayoutManager specifies a default constructor or one with the signature (Context, AttributeSet, int, int), RecyclerView will instantiate and set the LayoutManager when being inflated. Most used properties can be then obtained from getProperties(Context, AttributeSet, int, int). In case a LayoutManager specifies both constructors, the non-default constructor will take precedence.
我个人理解是这样的,LayoutManager暂且叫做布局管理器吧 ,布局管理器是负责测量和定位每一个子的view的,同时还有回收子view不再对用户可见的策略。而且还用来 用来这个布局管理器来控制RecyclerView的显示风格,比如我们常见的listview gridview 横向 竖向瀑布流等风格这个我会再之后的代码示例当中一一给出。
简单来说 需要记住两点:
1.RecyclerView 重点关注的是如何回收和复用View
2.通过LayoutManager来控制RecyclerView的显示风格
如果 我们在代码中有以下几种需求:
A.ListView的功能
B.GridView的功能
C.横向ListView
D.横向GridView
E.瀑布流
或者多种以上效果互相切换 则优先考虑用RecyclerView 而且代码简单只需要改变LayoutManager来实现
下面 我们通过代码逐一进行介绍。
- RecyclerView介绍(一)----简单概述
- RecyclerView(一)最简单的recyclerview
- RecyclerView的简单介绍
- RecyclerView简单使用介绍
- RecyclerView简单使用介绍
- spring概述介绍(一)
- RecyclerView详细介绍----基础使用(一)
- RecyclerView的使用介绍(一)
- RecyclerView使用介绍 一
- 简单概述SpringBoot(一)
- RecyclerView的简单使用--------------(一)
- RecyclerView的简单使用(一)
- Android RecyclerView简单入门介绍
- Android RecyclerView使用简单介绍
- RecyclerView使用的简单介绍
- (一)RecyclerView简单使用总结
- android RecyclerView的基本介绍及用法(一)
- JAXB(一)入门--概述,简单例子
- 10.缺陷跟踪系统Mantis介绍及安装
- 斐波那契数列数组递推,普通递归,记忆化搜索,矩阵快速幂,和公式法
- IOS中Json解析的四种方法
- svn使用常见问题
- 谷歌拼音输入法PinyinIME源码修改----随着Setting中中英文的切换对应改变软键盘中英文输入且字符变换
- RecyclerView介绍(一)----简单概述
- 求子数组的最大和
- ORACLE EBS 权限查询SQL
- java中转义字符
- ZOJ 1081 Points Within 判断点是否在多边形内
- iOS 开发者必不可少的 75 个工具
- Failed to open/create the internal network Vagrant on Windows10
- java -- 线程池例子ExecutorService
- 心情不好