Как сделать архитектуру сворачивающего меню профиля как в инстаграм?
В общем увидел такую классную штуку в инстаграме (а точнее во вкладке профиля), что при скролле в низ, у нас липнет к верху AppBarLayout. А потом когда скрол доходит до TabLayout то он липнет к нижней части AppBarLayout. Подскажите как это реализовать. Все мои попытки были четны.
Я объяснил как мог, поэтому если вы что-то не поняли из моего вопроса, я его дополню. Заранее спасибо.
Вот что мне нужно, заранее извиняюсь за гиф маленького размера.
То что сделал я но оно не работает. Скролиться только то что находиться в ViewPager всё остальное статично.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/abl_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:background="?attr/ColorAppBar"
app:elevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:orientation="horizontal"
android:padding="1.5dp">
<androidx.cardview.widget.CardView
android:id="@+id/cv_drawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="1dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="?attr/ColorAppBarCard"
app:cardCornerRadius="5dp"
app:cardElevation="0dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
android:rotation="180"
app:srcCompat="@drawable/ic_settings"
app:tint="?attr/ColorItem" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="1dp"
android:layout_weight="1"
app:cardBackgroundColor="?attr/ColorAppBarCard"
app:cardCornerRadius="5dp"
app:cardElevation="0dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/Menu"
android:textAllCaps="false"
android:textColor="?attr/ColorText1"
android:textSize="24sp"
android:textStyle="bold" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cv_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="1dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="?attr/ColorAppBarCard"
app:cardCornerRadius="5dp"
app:cardElevation="0dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
app:srcCompat="@drawable/ic_search"
app:tint="?attr/ColorItem" />
</androidx.cardview.widget.CardView>
</LinearLayout>
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/ctl_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/abl_menu"
app:layout_scrollFlags="scroll|enterAlways">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:padding="1.5dp" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/ColorItem" />
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ctl_menu"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tl_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/ColorAppBar" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_menu"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
