Maarten
Maarten

Reputation: 33

How can I make SectionList's section header stick to an offset?

In React-Native, can I make the sticky header in a SectionList stick to an instead of the top? I still want the list to render behind the offset. Also the header should not have a margin on the top when it's not sticking. Is there a way to do this?

Example of how I want the header to stick to the red line (offset): enter image description here

Upvotes: 1

Views: 1309

Answers (2)

sophon
sophon

Reputation: 231

iOS only, but you can use the contentInset prop, which is inherited from <ScrollView> to acheive this.

<SectionList contentInset={{ top: your_offset_amount }} ... />

Upvotes: 1

whalemare
whalemare

Reputation: 1326

You can hack it, by creating header with transparent height. For example, header has 100 height, where 80 it`s transparent offset and 20 it content

Upvotes: 0

Related Questions