Я хочу перекрыть первый элемент в RecyclerView с CollapsingToolbar , а также во время прокрутки элемент должен быть зафиксирован на CollapsingToolbar. Я пробовал следующее.
Файл макета
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/colay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_color">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleEnabled="false">
<info.devexchanges.parallaxheaderlistview.FixCollapsingToolbarLayout
android:id="@+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="280dp"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient"
android:orientation="vertical"
app:layout_collapseMode="parallax">
<TextView
android:id="@+id/txt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:paddingTop="15dp"
android:text="Hello there"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
android:textColor="@color/grey_20"
android:textSize="14sp" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:paddingTop="10dp"
android:text="@string/dummy_text"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
android:textColor="@android:color/white"
android:textSize="25sp" />
</LinearLayout>
</info.devexchanges.parallaxheaderlistview.FixCollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="-100dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
//app:behavior_overlapTop="100dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
tools:listitem="@layout/item_layout" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Я попытался использовать даже app:behavior_overlapTop="100dp"
в моем NestedScrollView, но тогда анимация прокрутки не происходит как требуется. Кроме того, после RecyclerView , который добавлен внизу, есть дополнительное пространство. Это происходит даже после удаления Negative Margin Я прочитал другие посты, но, похоже, ничего не работает. Может кто-нибудь дать мне правильное решение?