bgogetap / StickyHeaders

Easily add Sticky Headers to your RecyclerView
Apache License 2.0
521 stars 88 forks source link

StickHeader View covers whole screen when it stick at top #96

Closed ananth10 closed 4 years ago

ananth10 commented 4 years ago

Hi ,

I am trying to implement your sticker header library. i have done everything. but when i do scroll up the sticky header background color covers whole recyclerview. please check attached screenshot and let me whats wrong in this. before_stick_at_top after_stick_at_top

bgogetap commented 4 years ago

What does your layout hierarchy look like? Also could you post or summarize the XML for your item view that is sticky?

The view that is used as a sticky header is created the same way the RecyclerView creates it, by calling onCreateViewHolder on your adapter, followed by onBindViewHolder. The view from your view holder is then added to the parent of the RecyclerView.

This is why there is sometimes a need to wrap your RecyclerView that will have sticky headers in a FrameLayout. If your RecyclerView is a child that isn't the full width of the parent, this may happen (though a bit confused on the height filling out).

chetdeva commented 4 years ago

This was happening for me while inflating ViewHolder's itemView like such:

LayoutInflater.from(parent.context).inflate(layoutResId, null)

It got fixed when I did this:

LayoutInflater.from(parent.context).inflate(layoutResId, parent, false)
bgogetap commented 4 years ago

Closing due to no updates from reporter.

Thanks @chetdeva for a potential reason this could be happening.

Please reopen with a way to verify a repro of the issue if needed.