Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Header rows ignore ConstraintLayout/RelativeLayout directives #39

@stevesamknows

Description

@stevesamknows

Header items appear to be unable to use either percentage guidelines (if
using ConstraintLayout) or align-to-right (if using RelativeLayout). This is
unfortunate, because the data items themselves work perfectly with ConstraintLayout
percentage guidelines, useful for aligning data into columns. In our case
we want the subsection header row items to show labels for those columns,
but due to this issue the header row layout directives are ignored, causing
(severe) misalignment.

Even using ancient RelativeLayout is problematic as it also ignores directive
to align to parent right edge -- the workaround for now is to use RelativeLayout
and progressively lay items out left to right, but this puts us back in old-school
dpi level territory, which was eliminated when ConstraintLayout percentages
were introduced.

The image attached below demonstrates the same ConstraintLayout .xml (using percentage guidelines)
when used standalone vs. when added via SimpleRecylerView "SimpleSectionHeaderProvider"
(note that the data items themselves successfully use ConstraintLayout percentage
guidelines to arrange data in columns, but the header rows ignore those directives)
simplerecyclerview_header_rows_pull_left_not_expanding

Not doing anything fancy, should be similar to the bundled demo app (in kotlin) e.g.

    private fun addRecyclerHeaders(inflater: LayoutInflater, simpleRecyclerView: SimpleRecyclerView, historyListType: HistoryListType) {
        val sh = object : SimpleSectionHeaderProvider<SKResultsUIList>() {
            override fun getSectionHeaderView(skResultsUIList: SKResultsUIList, i: Int): View {
                val view = inflater.inflate(R.layout.result_history_list_header_card_view, null, false)
                ...
                return view
            }
            override fun isSameSection(currItem: SKResultsUIList, nextItem: SKResultsUIList): Boolean {
                return currItem.simpleRVCategory === nextItem.simpleRVCategory
            }

            // Optional, whether the header is sticky, default false
            override fun isSticky(): Boolean {
                return true
            }
        }
        simpleRecyclerView.setSectionHeader(sh)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions