У меня есть AppBarLayout с панелью инструментов и 2 кнопками. Он скрывается, когда я просматриваю RecyclerView вверх и показывает, когда я прокручиваю вниз. Проблема заключается в том, что RecyclerView установлен ниже AppBarLayout и сохраняет свою позицию, когда AppBarLayout скрывается, и у меня есть условие, показанное на картинке. Мне нужно, чтобы мой RecyclerView также прокручивался до панели состояния и возвращался в исходное положение при прокрутке вниз. До сих пор я даже не мог найти пример этого. Спасибо. RecyclerView: заполнить экран, когда AppBarLayout прокручивается (скрывается)
Это мт расположение:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ru.skyeng.listening.AudioFiles.AudioListActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
>
<ImageButton
android:id="@+id/action_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/gear"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_gravity="end"/>
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button_category"
android:layout_width="158dp"
android:layout_height="36dp"
android:layout_margin="16dp"
android:background="@drawable/selector_button_category"
android:text="@string/categories"
android:textColor="@color/colorBlue2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<Button
android:id="@+id/button_length"
android:layout_width="158dp"
android:layout_height="36dp"
android:layout_margin="16dp"
android:background="@drawable/selector_button_length"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="@string/length"
android:textColor="@color/colorBlue2"/>
<View
android:id="@+id/shadow"
android:layout_below="@+id/button_length"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="@drawable/shadow">
</View>
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_below="@+id/appBarLayout"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="24dp">
</FrameLayout>
</RelativeLayout>
вы можете показать нам свой XML? –
вам нужно использовать CoordinatorLayout - CollapsingToolbarLayout - проверьте здесь 9 здесь, как это сделать http://www.androidhive.info/2016/05/android-working-with-card-view-and-recycler-view/ – Tasos
@ Тассо, это определенно помогло. Если вы напишете какое-то объяснение для других, я помету ваш ответ как принятый. Большое спасибо. – Sermilion