Code Monkey home page Code Monkey logo

stickyitemdecoration's People

Contributors

chenpengfei88 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  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  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  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stickyitemdecoration's Issues

发现这种实现有种情况无法满足

对于黏连的view的高度是不同的话,你这个自定义的Decoration不能满足要求,只需要更改你的数据源既可以实现出来
`List performers = new ArrayList<>();

    Performer performer = new Performer("香港明星");
    performers.add(performer);

    Performer ldh = new Performer("刘德华", 10);
    performers.add(ldh);
    Performer zxy = new Performer("张学友", 10);
    performers.add(zxy);
    Performer zrf = new Performer("周润发", 10);
    performers.add(zrf);
    Performer lcw = new Performer("梁朝伟", 10);
    performers.add(lcw);
    Performer wyj = new Performer("吴毅将", 10);
    performers.add(wyj);
    Performer lm = new Performer("黎明", 10);
    performers.add(lm);
    Performer cgx = new Performer("陈冠希", 10);
    performers.add(cgx);
    Performer gfc = new Performer("郭富城", 10);
    performers.add(gfc);
    Performer xtf = new Performer("谢霆锋", 10);
    performers.add(xtf);

    Performer performerTw = new Performer("**明星:指的是****的一些有名气的电影,电视演员和歌手,他们具有很高的人气,成名时间早,成名时间久");
    performers.add(performerTw);

    Performer rxq = new Performer("任贤齐", 10);
    performers.add(rxq);
    Performer mtw = new Performer("孟庭苇", 10);
    performers.add(mtw);

    Performer performerTw2 = new Performer("**明星:指的是****的一些有名气的电影,电视演员和歌手,他们具有很高的人气,成名时间早,成名时间久");
    performers.add(performerTw2);

    Performer rxq2 = new Performer("罗志祥", 10);
    performers.add(rxq2);

    Performer performerTw3 = new Performer("**明星:指的是****的一些有名气的电影,电视演员和歌手,他们具有很高的人气,成名时间早,成名时间久");
    performers.add(performerTw3);

    Performer rxq3 = new Performer("李宗盛", 10);
    performers.add(rxq3);`

丢掉了分隔线功能?

recyclerView.addItemDecoration(new StickyItemDecoration());

本来addItemDecoration方法是用来给item添加分隔线的,如果使用以上代码的话,是不是就无法给item添加分隔线了?

涉及到了正序倒叙切换

正序倒叙切换的时候,清空数据从新请求后,title的第一条数据不会刷新,content的全部都能刷新

使用GridLayoutManager时,列表快速来回滑动,出现bug

使用GridLayoutManager处理多类型item时(有显示一行和多行的情况),列表快速来回滑动几次;
然后慢慢从最底部向上滑动到倒数第二个StickView,展示的数据有误,显示的是其他item的内容,感觉是复用或者是其他的问题。

吸附后的View如何设置点击事件

有个需求就是点击可以隐藏或打开列表,如何给吸附后的View设置点击事件,尝试了下没有解决,不知作者是否有好的方案,谢谢!

可以添加头吗?

比如demo中:
注释掉:
// Performer performer = new Performer("香港明星"); // performers.add(performer);

可以不显示下面的一个title?

动画效果

东西是好东西,好用,简单,使用多布局的方式完全解耦了,但是有一点,你的Decoration动画总感觉不是很顺滑,上滑动的时候上一个Decoration消失在屏幕上,这个Decoration还跟着上一个走了一段路才突然显示出来,没有那种连贯置顶的感觉,看了源码找不出原因

数据格式是两个层级的你这个怎么实现

[
{
"type_id": 1,
"type_name": "类型1",
"type_templet": [
{
"type_id": 1,
"templet_id": 2,
"templet_name": "时尚"
},
{
"type_id": 1,
"templet_id": 57,
"templet_name": "模板2"
},
{
"type_id": 1,
"templet_id": 59,
"templet_name": "rgte"
},
{
"type_id": 1,
"templet_id": 62,
"templet_name": "muban"
},
{
"type_id": 1,
"templet_id": 63,
"templet_name": "全球性"
},
{
"type_id": 1,
"templet_id": 65,
"templet_name": "rgter"
},
{
"type_id": 1,
"templet_id": 66,
"templet_name": "反而个人"
},
{
"type_id": 1,
"templet_id": 67,
"templet_name": "反而个人"
},
{
"type_id": 1,
"templet_id": 68,
"templet_name": "反而"
},
{
"type_id": 1,
"templet_id": 73,
"templet_name": "啦啦啦"
}
]
},
{
"type_id": 7,
"type_name": "类型7",
"type_templet": [
{
"type_id": 7,
"templet_id": 60,
"templet_name": "33"
},
{
"type_id": 7,
"templet_id": 64,
"templet_name": "模板1"
}
]
}
]

完善部分需求

实际运行中,这种粘连是随着数据排序跟着某一条数据出来的。
比如 手机通讯录用这种方式实现。那么数据肯定是不会像这样的,那么就需要处理展示数据的item了
以下是我的修改结果
1、StickyView 加入一个方法
/**
* 获取吸附View
*/
View getStickView(RecyclerView.ViewHolder vh);
在adapter中实现这个接口
@OverRide
public View getStickView(RecyclerView.ViewHolder vh) {
if (vh instanceof TitleVH) {
return ((TitleVH) vh).mTitle;
}
return null;
在顶部布局中,有两个控件,一个标题一个内容,此刻只获取标题的View
2、mStickyItemView的获取方式由原来的改为mStickyItemView = mStickyView.getStickView(mViewHolder);
3、bindDataForStickyView方法中原代码:// mStickyItemViewHeight = mViewHolder.itemView.getBottom() - mViewHolder.itemView.getTop();替换为mStickyItemViewHeight = mStickyItemView.getBottom() - mStickyItemView.getTop();
测试结果通过,可以,支持原效果能支持的需求

另建议:在具体适配器中实现StickyView接口 在构造中传入此接口。
如不介意:我会在我的github上传上我修改过后的代码,当然会加入你的链接
如有问题,请联系我,本人邮箱:[email protected]

最后一个吸附Title问题

当最后一个吸附Title的Content高度大于屏幕高度时,滑动到最后一个吸附Title时,此Title会闪动。
例如:将源码的getData()方法中 “导演” 及其子Content注释掉:
// Performer performerDy = new Performer("导演");
// performers.add(performerDy);
// Performer jzk = new Performer("贾樟柯", 10);
// performers.add(jzk);
// Performer ly = new Performer("李杨", 10);
// performers.add(ly);
// Performer fxg = new Performer("冯小刚", 10);
// performers.add(fxg);
// Performer lyy = new Performer("娄烨", 10);
// performers.add(lyy);
// Performer zym = new Performer("张艺谋", 10);
// performers.add(zym);

此时滑动到“NBA明星”的吸附Title时,此吸附Title闪动(与其他吸附Title过度效果不一致)。

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.