ConstraintLayout RecyclerView отображается в BottomNavigationView - PullRequest
0 голосов
/ 30 августа 2018

Как заставить RecyclerView не отображаться в BottomNavigationView с ConstraintLayout.

Вот результат (рециркулятор должен отображать 20 элементов)

enter image description here

А вот и xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/myListSimple"
        android:scrollbars="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation"/>

</android.support.constraint.ConstraintLayout>

1 Ответ

0 голосов
/ 30 августа 2018

Вы используете match_parent для android:layout_width и android:layout_height для RecyclerView, что не рекомендуется для Views, содержащегося в ConstraintLayout. Вы должны использовать 0dp вместо того, чтобы соответствовать ограничениям:

<android.support.v7.widget.RecyclerView
    android:id="@+id/myListSimple"
    android:scrollbars="vertical"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toTopOf="@id/navigation"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
...