Java Code Examples for androidx.recyclerview.widget.GridLayoutManager#setSpanCount()
The following examples show how to use
androidx.recyclerview.widget.GridLayoutManager#setSpanCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApplyFragment.java From candybar with Apache License 2.0 | 6 votes |
private void resetSpanSizeLookUp() { int column = getActivity().getResources().getInteger(R.integer.apply_column_count); LauncherAdapter adapter = (LauncherAdapter) mRecyclerView.getAdapter(); GridLayoutManager manager = (GridLayoutManager) mRecyclerView.getLayoutManager(); try { manager.setSpanCount(column); manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { if (position == adapter.getFirstHeaderPosition() || position == adapter.getLastHeaderPosition()) return column; return 1; } }); } catch (Exception ignored) { } }
Example 2
Source File: RcvSectionMultiLabelAdapter.java From RecyclerViewAdapter with Apache License 2.0 | 6 votes |
@Override public void onAttachedToRecyclerView(RecyclerView recyclerView) { RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager instanceof GridLayoutManager) { final GridLayoutManager gridManager = ((GridLayoutManager) manager); gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { if (isInHeadViewPos(position) || isInSectionLabelPos(position) || isInFootViewPos(position) || isInLoadMorePos(position) || isInEmptyStatus()) return gridManager.getSpanCount(); else return 1; } }); gridManager.setSpanCount(gridManager.getSpanCount()); } }
Example 3
Source File: RcvMultiAdapter.java From RecyclerViewAdapter with Apache License 2.0 | 5 votes |
/** * 添加HeadView或FootView或LoadMore或EmptyView * 兼容GridLayoutMananger的方法 */ @Override public void onAttachedToRecyclerView(RecyclerView recyclerView) { super.onAttachedToRecyclerView(recyclerView); RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager instanceof GridLayoutManager) { final GridLayoutManager gridManager = ((GridLayoutManager) manager); gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { if (isInHeadViewPos(position) || isInFootViewPos(position) || isInLoadMorePos(position) || isInEmptyStatus()) { return gridManager.getSpanCount(); } else { return 1; } } }); gridManager.setSpanCount(gridManager.getSpanCount()); } }
Example 4
Source File: AutoColumnGridLayoutManager.java From RecyclerExt with Apache License 2.0 | 5 votes |
@Override public void onGlobalLayout() { removeOnGlobalLayoutListener(recyclerView, this); GridLayoutManager gridLayoutManager = (GridLayoutManager)recyclerView.getLayoutManager(); gridLayoutManager.setSpanCount(determineColumnCount(requestedColumnWidth)); }