I want a ListView style RecyclerView with a header on top, AND I don't want the header view to get recycled, EVER.
I'm totally new to RecyclerView
and LinearLayoutManager
but I think what I want shouldn't be too difficult by extending LinearLayoutManager
.
Additional info in case needed, but I think the above is enough:
I already have a RecyclerView with a header view at position 0. That part was easy enough with help from SO answers. But the view gets recycled, which is causing lots of issues with the EditText views in the header (trying to keep focus, restore focus, keep the caret visible, not do weird things with auto-correct feature, keep typing while EditText is technically gone/recycled, etc). So the simple solution would be to not have that view recycled, which I think is possible with a custom layout manager, but I have no idea where to begin.
I can't simply place the header view above my list, because I want it to scroll with the list (it's too tall to be fixed at the top of screen all the time).
LayoutManager
has LayoutManager#ignoreView(View) interface which according to documentation,
Flags a view so that it will not be scrapped or recycled.
Looks like what you need here
EDIT Google devs commented (here) that this flag is serving some other purpose, so it is not gonna solve "RecyclerView Header" problem. However, they are working on solution, so hold on tight and stay tuned
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With