GithubHelp home page GithubHelp logo

Comments (8)

jonathanyee avatar jonathanyee commented on May 17, 2024

I tried making my 5dp divider into a row in the adapter and it broke the sticky header animation when it reaches a new header.

from flexibleadapter.

davideas avatar davideas commented on May 17, 2024

Hello @jonathanyee, you can create a custom ItemDecoration that displays the divider only when the next item is a header (avoiding the very first header of the list), and that should be the way to do it.
We can try to work on it and if it is useful, we can include it in the library.

But you want an easier workaround, and if i understood well maybe you miss to set the same header also to the divider item (defined as ISectionable). If not, we need to investigate a bit more.

from flexibleadapter.

jonathanyee avatar jonathanyee commented on May 17, 2024

How would I detect the next item is a header?

from flexibleadapter.

davideas avatar davideas commented on May 17, 2024

@jonathanyee, The idea is to combine some code of StickyHeaderHelper class and also the ItemDecoration in the project https://github.com/edubarr/header-decor.

Basically with RecyclerView.getChildAt(position) and RecyclerView.getChildAdapterPosition(child) and with my function isHeader(Item) I think it's possible to understand if a next item is a header. Then calculate the margins to create space between the items.
I know it is difficult and it requires time. I will have a look in some weeks if I have time. For the moment it is better if you use the divider item...

from flexibleadapter.

davideas avatar davideas commented on May 17, 2024

@jonathanyee, I've modified the DividerItemDecoration to add a gap space (offset) only at the end of a section with items, now if you don't want the middle lines, the code in onDraw() method should be skipped to be executed. If you desire, would you customize that class for this library? lot of improvements can be done, for instance:

  • support for horizontal
  • accepting a drawable object

from flexibleadapter.

davideas avatar davideas commented on May 17, 2024

The modification I've added seems to work only with LinearLayout, with GridLayout it doesn't create the gap for the previous items that are on the same line of the last item... so, for Grid it must be fixed! Any idea?

from flexibleadapter.

jonathanyee avatar jonathanyee commented on May 17, 2024

I'm sorry, can't think of any.

from flexibleadapter.

davideas avatar davideas commented on May 17, 2024

Available from v5.0.0-b6.

from flexibleadapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.