1.在ScrollView的RecylerView滑动事件的处理。

在布局文件中在RecylerView外包裹一层相对布局

2.RecylerView item之间的距离

(1)编写SpaceItemDecoration

 /**
* 设置RecycleView Item之间的间距的类
*/
class SpaceItemDecoration extends RecyclerView.ItemDecoration {
int mSpace; /**
* Retrieve any offsets for the given item. Each field of <code>outRect</code> specifies
* the number of pixels that the item view should be inset by, similar to padding or margin.
* The default implementation sets the bounds of outRect to 0 and returns.
* <p>
* <p>
* If this ItemDecoration does not affect the positioning of item views, it should set
* all four fields of <code>outRect</code> (left, top, right, bottom) to zero
* before returning.
* <p>
* <p>
* If you need to access Adapter for additional data, you can call
* {@link RecyclerView#getChildAdapterPosition(View)} to get the adapter position of the
* View.
*
* @param outRect Rect to receive the output.
* @param view The child view to decorate
* @param parent RecyclerView this ItemDecoration is decorating
* @param state The current state of RecyclerView.
// */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.left = mSpace;
outRect.right = mSpace;
outRect.bottom = mSpace;
if (parent.getChildAdapterPosition(view) == 0) {
outRect.top = mSpace;
} } public SpaceItemDecoration(int space) {
this.mSpace = space;
}
}
(2)rv_home_local.addItemDecoration(new SpaceItemDecoration(15)); 3.小数取整

Android中Math类中提供了三个与取整有关的方法:


分别是ceil、floor、round,这些方法的作用与它们的英文名称的含义相对应


ceil的英文解释是天花板,该方法就表示向上取整,所以,Math.ceil(16.2)的结果为17,Math.ceil(-16.2)的结果是-16;


floor的英文解释是地板,所以该方法就表示向下取整,那么Math.floor(16.6)的结果为16,Math.floor(-16.6)的结果是-17;


round方法比前两个稍微复杂一点,它表示“四舍五入”,算法为Math.floor(x+0.5),即将原来的数字加上0.5后再向下取整,所以,Math.round(16.2)的结果为16,Math.round(-16.2)的结果为-16.

												

最新文章

  1. EBS 中经常用到的一些值集
  2. Python-Django进阶
  3. InnoDB配置文件复习
  4. Testing - 测试基础 - 概念
  5. ORA-02287: 此处不允许序号
  6. MSBI--enlarge the DW database table volume
  7. .NET_Framework_version_history
  8. 跟我一起学习ASP.NET 4.5 MVC4.0(四)(转)
  9. 【转】mysql in语句优化
  10. ASP.NET 学习小记 -- “迷你”MVC实现(2)
  11. debian下安装AMD驱动
  12. 1000 A+B [ACM刷题]
  13. Hopscotch(细节)
  14. Funsion Charts 学习(一)
  15. Git操作流水账
  16. maven copy 依赖jar包
  17. 转:eclipse 设置Java快捷键补全
  18. ES 6 proimse &amp;&amp;iterator &amp;&amp;Generator函数 &amp;&amp;async
  19. Spring中bean实例化的三种方式
  20. 使用Visual Studio 2017开发Linux程序

热门文章

  1. node中的__dirname
  2. 【Linux】- 文件基本属性
  3. python Django框架接入微信公众平台
  4. (转)Elasticsearch .net client NEST使用说明 2.x
  5. WebKit 源码分析 -- loader
  6. 第52天:offset家族、scroll家族和client家族的区别
  7. javabean 参数收集 设置属性 设置不同级别的域对象的属性 默认存储在pagecontext中
  8. 【codevs1380】没有上司的舞会 树形dp
  9. CentOS 查看系统内核和版本
  10. warning: React does not recognize the xxx prop on a DOM element