I have used CoordinatorLayout for getting Appbar + RecyclerView scroll behavior. But I'm not able to achieve overlapping of Appbar over the RecyclerView within this CoordinatorLayout. I have tried using negative margins which works but I don't know if that is a good practice. Is there any other way to achieve this?
The following code is the original xml without negative margins:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
...
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:elevation="0dp"
android:clipToPadding="false"
android:background="@color/transparent"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="match_parent"
...
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
[Edit] I tried encapsulating Appbar + RecyclerView within RelativeLayout before putting them in CoordinatorLayout (see Overlapping views in coordinatorlayout) but that just breaks the "hide appbar on scroll" behavior.