如何将主单元格放在StaggeredGridLayout(回收者视图)的顶部? [英] How to put main cell on the top of StaggeredGridLayout(recycler view)?

查看:89
本文介绍了如何将主单元格放在StaggeredGridLayout(回收者视图)的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Recycler View

我需要什么:

我可以将回收站视图分为两列,但是我不知道如何将主单元格放在回收站视图的顶部

I can divide recycler view to 2 columns, but I don't know how to put main cell on top of the recycler view

我不确定,但是也许我可以将其放入容器中并尝试在滚动过程中将其隐藏?就像我们在用户开始滚动工具栏时使用工具栏一样.

I am not sure, but maybe I can put it in container and try to hide it during scrolling? Like we do with toolbar when user start to scroll toolbar gone up.

但是我不确定

如何将主单元格放在StaggeredGridLayout(回收者视图)的顶部?

How to put main cell on the top of StaggeredGridLayout(recycler view) ?

提前谢谢!

推荐答案

在onBindViewHolder方法中添加这些行

Add these lines in onBindViewHolder method

if(position == 0){
      StaggeredGridLayoutManager.LayoutParams layoutParams =  (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
      layoutParams.setFullSpan(true);
}

这篇关于如何将主单元格放在StaggeredGridLayout(回收者视图)的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆