wustor / gangedrecyclerview Goto Github PK
View Code? Open in Web Editor NEWRecyclerview实现双列表联动,列表悬停
Home Page: https://juejin.cn/post/6844903508882391047
Recyclerview实现双列表联动,列表悬停
Home Page: https://juejin.cn/post/6844903508882391047
点击左侧栏目,然后滑动右侧,发现只有滑动两个栏目左侧才会跳转,eg:点击保健品,滑动右侧,左侧只会跳转西药或者消毒品,不会跳转普通食品或医疗器械。
如果右边是LinearLayoutManager时,需要怎么做
如题目所描述的那样. 我试着把 Demo 里边的 item_title 的高度改成大于 item_classify_detail 的高度, 测试发现可以出现同样的问题.
我自己也在想怎么解决这个问题, 虽然还没有解决办法. 可以帮我看一下吗?
楼主在吗,demo中发现一个小bug 点击选中左侧的某一项,然后缓慢滑动右侧的列表,当右侧列表滑动到下一项时,左侧的下一项并不会被选中,继续滑动到下一项,左侧选中状态才恢复正常。
代码封装的太好了不会在fragment中使用,可能是context传递的一些问题。那些类是必要的,为什么会用到fragment。好像是因为getAssetsData没有获取到数据,String assetsData = getAssetsData("sort.json")这个数据是怎么得到的。找到了,要在assets中放入模拟数据,谢谢大神,代码很好用。
现在如果最下面的item 内容太少了,就无法联动了, 是否考虑增加一个foot view 来使得最下面的item在内容太少的时候也能顶上去
当右边的数据很多的时候,点击左边的菜单栏会有卡顿,有时超过了三秒才滑动到相应的位置,这个可以优化下么?
还有如果右边的数据展示改成一行只显示一个数据的时候,往上滑动的时候,当滑到这个列表倒数第二个的时候,头部的标题栏就被顶上去了,然后又回来的?直到这个分类滑完后标题栏才消失的,、。
麻烦解答下,谢谢
谢谢大佬对每个意见都回复
那个 我又发现一个bug,比如左侧我选了1 ,然后滑动至1不可见,滑动右边的会崩
在MainActivity的setChecked(int position, boolean isLeft)方法里面少了这句代码rvSort.smoothScrollToPosition(position);
还有就是滑动右侧的,左侧的要是不可见,将其滑动至可见应该会比较好吧, 类似拼多多 搜索界面的效果
private class SurplusListener extends RecyclerView.OnScrollListener {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
mSurplusHeight = mSurplusLayout.getHeight();
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
/**
* 这块主要是比对当前的可见的第一个元素 之后的元素是否和其是同一组,如果不是
* 即下一部分必为Title,所以即执行粘性头操作.
*/
//TODO 这一块 实现的方式感觉还是太Low
int pos = mLayoutManager.findFirstVisibleItemPosition();
int spanSize = mLayoutManager.getSpanSizeLookup().getSpanSize(pos);
//spanSize == 1代表的是当前Item只占1个格子,而每行有三个格子
if (spanSize == 1) {
String tag = contents.get(mCurrentPosition).getTag();
String tag1 = contents.get(mCurrentPosition + 1).getTag();
String tag2 = contents.get(mCurrentPosition + 2).getTag();
String tag3 = contents.get(mCurrentPosition + 3).getTag();
Log.d("比较值", "tag : " + tag + "----tag1 : " + tag1 + "----tag2 : " + tag2 + "----tag3 : " + tag3);
//因为1行有3个元素,这时候需要考虑不同的情况,然后确定位置.
if (!TextUtils.equals(tag, tag1)) {
changeHeader(mCurrentPosition + 1);
} else if (!TextUtils.equals(tag, tag2)) {
changeHeader(mCurrentPosition + 2);
} else if (!TextUtils.equals(tag, tag3)) {
changeHeader(mCurrentPosition + 3);
}
}
if (mCurrentPosition != mLayoutManager.findFirstVisibleItemPosition()) {
mCurrentPosition = mLayoutManager.findFirstVisibleItemPosition();
mSurplusLayout.setY(0);
//更新假头的显示内容
int tag = Integer.parseInt(contents.get(mCurrentPosition).getTag());
updateSuspensionBar(tag);
}
}
/**
* 改变粘性头,使其滑动
* 实现粘性头的核心
*/
private void changeHeader(int position) {
View view = mLayoutManager.findViewByPosition(position);
if (view != null) {
if (view.getTop() <= mSurplusHeight) {
mSurplusLayout.setY(-(mSurplusHeight - view.getTop()));
} else {
mSurplusLayout.setY(0);
}
}
}
}
if (isTranslate) {
canvas.restore();
}
Log.d("tag--->", tag + "VS" + currentTag);
if (!TextUtils.equals(tag, currentTag)) {
currentTag = tag;
Integer integer = Integer.valueOf(tag);
mCheckListener.check(integer, false);
}
最下面一行 有时候出现报空的情况,这个我也无法复现,不知道什么时候会报,有时候是界面被覆盖时候太久时间时候出现的,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.