question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to acomplish Sticky header

See original GitHub issue

I did all the steps according to the wiki and the demo but the headers are not sticking at all. The sections are fine but the header scrolls out of the page @davideas What else I should try?

Obs:

  • ‘eu.davidea:flexible-adapter:5.0.0-b8’

  • Using the same fragment_recycler_view.xml

  • HeaderItem extends AbstractHeaderItem<HeaderItem.HeaderViewHolder>

  • Item extends AbstractFlexibleItem<Item.ItemViewHolder> implements ISectionable<Item.ItemViewHolder, HeaderItem>

    adapter = new FlexibleAdapter<>(items);
    recycler.setLayoutManager(new SmoothScrollLinearLayoutManager(getContext()));
    adapter.setDisplayHeadersAtStartUp(true);
    adapter.enableStickyHeaders();
    recycler.setAdapter(adapter);
    recycler.setHasFixedSize(true);
    recycler.setItemAnimator(new DefaultItemAnimator());

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
llleodeleoncommented, Dec 1, 2016

@davideas Found it! I was implementing this method wrong. Now it works!

@Override
  public boolean equals(Object inObject) {
    if (inObject instanceof HeaderItem) {
      HeaderItem inItem = (HeaderItem) inObject;
      return this.getId().equals(inItem.getId());
    }
    return false;
  }
1reaction
davideascommented, Nov 30, 2016

@leodeleon22, I see now that, you enable the headers before setting the Adapter. Move the assignment after. The layout needs the RV attached (means not null) before inflating the sticky container.

Be aware that I’m going to change this configuration, in the next pre-release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

position:sticky is not working - Stack Overflow
.header has a height of 150px. .navbar has a height of 20px. When the user scrolls, I want .navbar to stick at the...
Read more >
Lightning Web Component Sticky Header - Not able to global ...
I have defined sticky2 to class for a sticky header. Js controller /* eslint-disable no-console */ import { LightningElement } from 'lwc'; ...
Read more >
Header Sticky does not work (Pro) - WordPress.org
The header is currently sticky because of my custom CSS–the header sticky customizer option still isn't working. And neither is the scroll to...
Read more >
Stop Using Fixed Headers and Start Using Sticky Ones
By using position: fixed on an element like the header, the element is removed from the stack and positioned relative to the browser...
Read more >
Sticky Headers: 5 Ways to Make Them Better
1. Maximize the Content-to-Chrome Ratio by Keeping It Small. Sticky headers inherently take up space on the screen that could be used for ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found