Установите максимально видимые элементы в RecylerView, после этого прокрутите список - PullRequest
0 голосов
/ 18 июня 2019

У меня есть RecyclerView внутри BottomSheetBehavior.В этом RecyclerView у меня есть переменное количество предметов.(без минимума, без максимума)

Проблема в том, что после определенного количества элементов (в зависимости от высоты устройства) BottomSheet перекрывает панель инструментов и т. д.

Поэтому я хочу установить maxHeight дляRecyclerView, но он не работает.Я думаю, что это игнорируется.

Мой включенный макет (в CoordinatorLayout)

<androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/cart_bottom_sheet"
            app:behavior_peekHeight="0dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_anchor="@+id/cooking_item_list_content"
            app:layout_anchorGravity="bottom"
            app:layout_behavior="@string/bottom_sheet_behavior">

    <androidx.appcompat.widget.AppCompatTextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/cart_text_items"
            android:textSize="@dimen/text_size_medium"
            tools:text="@string/cookingprogram_cart_entries"
            app:layout_constraintStart_toEndOf="@+id/cart_text_item_count"
            app:layout_constraintTop_toTopOf="@+id/cart_text_item_count"
            app:layout_constraintBottom_toBottomOf="@+id/cart_text_item_count"
            app:layout_constraintEnd_toStartOf="@+id/cart_button_submit"/>

    <androidx.appcompat.widget.AppCompatImageButton
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:srcCompat="@drawable/transfer_cooking_program_active"
            app:layout_constraintDimensionRatio="1:1"
            android:id="@+id/cart_button_submit"
            android:background="@color/colorPrimary"
            app:layout_constraintBottom_toTopOf="@id/cart_recyclerview"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintEnd_toEndOf="parent"/>

    <androidx.recyclerview.widget.RecyclerView
            android:layout_width="match_parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:visibility="gone"
            android:id="@+id/cart_recyclerview"
            android:maxHeight="200dp" //does not work
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cart_button_submit"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent">

    </androidx.recyclerview.widget.RecyclerView>

</androidx.constraintlayout.widget.ConstraintLayout>

Что я в основном хочу, это что-то вроде .setMaxVisibleItems(5) или что-то подобное.Есть идеи?

enter image description here

...