Code Monkey home page Code Monkey logo

recyclerviewnestedrecyclerview's Introduction

RecyclerviewNestedRecyclerview

An example of a recyclerview nested recyclerview

  最近项目中用到了两个RecyclerView嵌套的布局,即RecyclerView的item也是RecyclerView,其中遇到了两个比较典型的问题:1、当item的方向是垂直方向时,父RecyclerView首次加载会出现位移;2、当item的方向是水平方向时,父RecyclerView上下滑动之后,子RecyclerView位置会还原,本文主要解决以上两个问题。我们先来瞄一眼这两个问题的效果图:

修复前.gif

来瞄一眼解决问题后的效果图:

修复后.gif

 源码解析: http://www.jianshu.com/p/91b6ef2c4c29

recyclerviewnestedrecyclerview's People

Contributors

enjoyandroid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

recyclerviewnestedrecyclerview's Issues

滑动回到初始状态偏移问题

int offset = recyclerView.computeHorizontalScrollOffset();
if (offset > 0 && mItemWidth > 0) {
mEntity.scrollOffset = mItemWidth - offset % mItemWidth + mEntity.scrollPosition * mItemMargin;
}

这段 如果 offset 是0(回到初始位置),那么offset永远不会赋值了,每次回到初始位置都是错的。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.