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

Header rows ignore ConstraintLayout/RelativeLayout directives #39

Open
stevesamknows opened this issue May 15, 2018 · 6 comments
Open

Comments

@stevesamknows
Copy link

stevesamknows commented May 15, 2018

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)
    }

@stevesamknows stevesamknows changed the title Header layout constraints ignored Header rows ignore ConstraintLayout/RelativeLayout directives May 15, 2018
@stevesamknows
Copy link
Author

Probably duplicate of #32

@stevesamknows
Copy link
Author

Tested another workaround: horizontal LinearLayout using weights to approximate percent widths
(e.g. with weight of "1" and 8 elements, each element should be 12.5% of the width)
But again (surprisingly with such a simple legacy layout) it all pulls severely left as above,
simply has no concept of filling the parent width

@stevesamknows
Copy link
Author

Testing is as easy as modifying demo project to use a very simple RelativeLayout
with two textViews; align one to parent right edge -- expect both to overlap at left edge
at runtime

@jaychang0917
Copy link
Owner

Version 2.0.3 should fix this issue.

@stevesamknows
Copy link
Author

Excellent -- works great, thank you for very fast turnaround

@stevesamknows
Copy link
Author

The width is now fixed, but height seems to have the same issue -- height will squash down
to wrap content, and directives to expand (e.g. specifying a generous height in dp) will be
ignored -- reopening

@stevesamknows stevesamknows reopened this May 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants