bgogetap / StickyHeaders

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

Positioner does not account for insets applied by parent layout #54

Open bgogetap opened 7 years ago

bgogetap commented 7 years ago

If a RecyclerView is nested inside a CoordinatorLayout, the sticky header may not be stuck at the right position depending on insets applied.

Reproduction steps:

<android.support.design.widget.CoordinatorLayout>
    <android.support.design.widget.AppBarLayout>
        <LinearLayout>
            /..stuff../
        </LinearLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView/>
</android.support.design.widget.CoordinatorLayout>
bgogetap commented 7 years ago

Currently the workaround for this is to wrap the RecyclerView in a FrameLayout.

This fix is on my radar, but slightly low priority given the simple (though undesired because of extra view nesting) fix.

themichaelscott commented 6 years ago

To use the workaround suggested above, you also need move the appbar_scrolling_view_behavior from the RecyclerView to the FrameLayout so it will be positioned below the AppBarLayout properly. An easy thing to remember to do, but I forgot so I thought I'd help anyone else out who comes across it.

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    >
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
</FrameLayout>
mobilekosmos commented 4 years ago

Could you please fix this? Yes, the workaround works, but please be so kind to fix this, it happens again and again that somebody forgets/doesn't know that this is needed.