Skip to content

Section Layout Manager Reference

TonicArtos edited this page Dec 19, 2014 · 1 revision

About

The SectionLayoutManager's (SLM) job is to properly position views belonging to a single logical section. How those views are positioned is nearly entirely up to the SLM, it just has to stay within a few constraints imposed by the LayoutManager (LM).

The SLM also has a few extra tasks to do as the LM needs to know a few things in order to orchestrate the proper positioning of headers and sections.

Fill Strategies

When laying out views the SLM is called to do so in one of three ways, to fill out views from a given position towards the end of the view area, or from a position towards the start, or to fill out in both directions from the position. There are actually two position data points. The adapter view position which is called the anchorPosition, and the marker line, which is the on-screen location from where to lay out views relative to. The LM also passes in a few helpers and some metadata about the section being laid out.

The SLM should only lay out views belonging to its own section, it should not lay out views completely beyond the edges of the RecyclerView, and it should not lay out the section header.

START

The START fill strategy expects the section to be laid out from the marker line, and not below that line, towards the start edge of the RecyclerView. The SLM should stop laying out views once it has passed the start edge or it has run out of views in its section. Remember to ignore the header for the section, the LM will lay it out for you.

It is expected that START strategy will fill an area towards the start edge which equals or exceeds a minimum size as determined by the section header. This is usually met by laying out all the views towards the start edge, and then checking against the minimum size requirement and then off-setting the added views towards the start edge by the required amount.

The START strategy will always start with the last view in the section.

END

The END fill strategy expects the section to be filled out from the marker line, and not above that line, towards the end edge of the RecyclerView.

As the END strategy starts from the beginning of the section, it is easy to check against the minimum size requirement, and if it is not met, simply bump along the end marker by the required amount before returning it to the LM.

The END strategy will always start with the first non-header view in the section.

BOTH

The BOTH strategy gives a marker line from which it is expected the anchor position will be filled below. The approach used by the LinearSectionLayoutManager is to fill below the marker line from the anchor position towards the end edge first, and then to fill towards the start edge above the marker line from the position immediately before the anchor position.

Header Offsets

and some other things

Versioned Pages

0.4

[Getting Started](Getting started with version 0.4)
[User's Guide](User's guide for version 0.4)

version5 (WIP)

User documentation
[Basic usage](A simple tutorial)
[Advanced usage](All the cool things)
[SuperSLiM and RxJava](Using SuperSLiM with RxJava)

Developers documentation
Glossary
[The section graph](The section graph)
[Tracking data changes](Tracking data changes)
[Configuration transformations](Configuration transformations)
[Layout helpers](Layout helpers)
[Section configuration](Section configuration)
[Section state](Section state)
[Section layout managers](Section layout managers)
[Header layout managers](Header layout managers)

Clone this wiki locally