RecyclerView应用
RecyclerView 实现网页分格布局 GridLayoutManager+SnapHelper+ 坐标转换 具体实现见 PagingRecyclerView PagerGridLayoutManager Ref 其他一些开源库 https://github.com/hanhailong/GridPagerSnapHelper 不支持 ...
RecyclerView 实现网页分格布局 GridLayoutManager+SnapHelper+ 坐标转换 具体实现见 PagingRecyclerView PagerGridLayoutManager Ref 其他一些开源库 https://github.com/hanhailong/GridPagerSnapHelper 不支持 ...
RecyclerView 基本使用 RecyclerView 类的分工 RecyclerView.Adapter 处理数据集合并负责绑定视图 ViewHolder 持有所有的用于绑定数或者需要操作的 View LayoutManager 负责摆放视图等相关操作 ItemDecoration 负责绘制 Item 分割线 ItemAnimator 为 Item 操作添加...
RecyclerView 性能优化 RecyclerView 定向刷新 notifyItemXXX payloads DiffUtil SortedList AsyncListUtil setHasStableIds()/getItemId() 它只会在调用 notifyDataSetChanged 方法之后,影响 RecyclerView 的行为。 setHas...
Fragment 生命周期 Fragment 生命周期简单版 onAttach():Fragment 和 Activity 相关联时调用。可以通过该方法获取 Activity 引用,还可以通过 getArguments() 获取参数。 onCreate():Fragment 被创建时调用onActivityCreated():当 Activity 完成 onCreate()...
Fragment 常见坑 Fragment 踩过的坑 内存重启: app 运行在后台的时候,系统资源紧张的时候导致把 app 的资源全部回收(杀死 app 的进程),这时把 app 再从后台返回到前台的时候,app 会重启;回收之前,系统会把 Activity 的状态保存下来,Activity 的 FragmentManager 负责把 Activity 的 Fragment 保存起来。...
CoordinatorLayout CoordinatorLayout(协调者布局) 是在 Google IO/15 大会发布的,遵循 Material 风格,包含在 support Library 中,结合 AppbarLayout, CollapsingToolbarLayout 等可产生各种炫酷的效果。 CoordinatorLayout 主要实现以下四个功能 处理子控件的...
CollapsingToolbarLayout 介绍 CollapsingToolbarLayout 是用来对 Toolbar 进行再次包装的 ViewGroup,主要是用于实现折叠(其实就是看起来像伸缩~)的 App Bar 效果。它需要放在 AppBarLayout 布局里面,并且作为 AppBarLayout 的直接子 View。CollapsingToolbarLayout 主要...
AppbarLayout AppbarLayout 介绍、用途 AppBarLayout,顾名知意,就是用来给 AppBar 布局的容器,是 LinearLayout 的子类。而 AppBar 就包含我们通常所知道的 ActionBar,Toolbar。 AppBarLayout 继承自 LinearLayout,布局方向为垂直方向。所以你可以把它当成垂直布局的 LinearLayou...
ConstraintHelper Optimizer(layout_optimizationLevel) 当我们使用 MATCH_CONSTRAINT 时,ConstraintLayout 将对控件进行 2 次测量,ConstraintLayout 在 1.1 中可以通过设置 layout_optimizationLevel 进行优化。 版本中添加了几个新的优化点,可加快您的布...
ConstraintLayout 应用场景 半透布局,居中对齐 1. 要相对 view 的 bottom,xxx_toBottomOf app:layout_constraintBottom_toBottomOf="@id/tv1" app:layout_constraintTop_toBottomOf="@id/tv1" 2. 要相对于 view 的 top,xxx_toTopO...