I want add a headerview like listview into recyclerview with staggeredGridLayoutManager. I have search all library and only found this one RecyclerHeaderView but this library have limitation for LinearLayoutManager or GridLayoutManager. Is possible to add headerview for staggeredGridLayout?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
you can use setFullSpan in the layout manager to create a row that looks like a header
public final void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) viewHolder.itemView.getLayoutParams();
layoutParams.setFullSpan(true);
}