ConstrainLayout - нижняя навигация перекрывает RecyclerView - PullRequest
0 голосов
/ 28 мая 2020

У меня есть ConstraintLayout с AppBar, 2 фрагмента (каждый фрагмент содержит RecyclerView) и нижнюю навигацию. Проблема в том, что нижняя панель навигации перекрывает последнюю строку RecyclerView.

Это мой макет

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/template_grey_dark"
    tools:context=".presentation.ui.activity.MainActivity">

    <include
        android:id="@+id/AppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        layout="@layout/app_bar" />

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/SwipeRefreshLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        *app:layout_constraintTop_toBottomOf="@+id/AppBar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">
        <androidx.core.widget.NestedScrollView
            android:id="@+id/NestedScrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipToPadding="true"
            android:fillViewport="true"
            android:fitsSystemWindows="true"
            android:padding="@dimen/activity_horizontal_margin_8">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <androidx.fragment.app.FragmentContainerView
                    android:id="@+id/FragmentMovie"
                    android:name=".presentation.ui.fragment.MovieFragment"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    tools:layout="@layout/fragment_movie"
                    android:layout_marginTop="@dimen/activity_horizontal_margin_16"/>
                <androidx.fragment.app.FragmentContainerView
                    android:id="@+id/FragmentTVShow"
                    android:name=".presentation.ui.fragment.TVShowFragment"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    tools:layout="@layout/fragment_tv_show"
                    android:layout_marginTop="@dimen/activity_horizontal_margin_16"/>
            </LinearLayout>
        </androidx.core.widget.NestedScrollView>
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
    <LinearLayout
        android:id="@+id/FabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintBottom_toTopOf="@+id/BottomNavigationLayout"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:gravity="end">
        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:src="@mipmap/baseline_filter_list_white"
            android:contentDescription="I'm Feeling Lucky"
            android:layout_margin="@dimen/activity_vertical_margin_16"
            app:backgroundTint="@color/black"
            app:tint="@color/white"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/BottomNavigationLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">
        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/BottomNavigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:menu="@menu/bottom_navigation"
            android:background="@color/black"
            style="bottomNavigationStyle"/>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Если я добавлю

app:layout_constraintBottom_toTopOf="@+id/BottomNavigationLayout"

в SwipeRefreshLayout, он сделает ничего.

Есть идеи, в чем может быть проблема?

1 Ответ

1 голос
/ 28 мая 2020

Измените refre смахивания sh *app:layout_constraintTop_toBottomOf="@+id/AppBar" на app:layout_constraintTop_toBottomOf="@id/AppBar" и app:layout_constraintBottom_toTopOf="@id/+BottomNavigationLayout" на app:layout_constraintBottom_toTopOf="@id/BottomNavigationLayout" и, наконец, установите высоту SwipeRefreshLayout на 0dp, чтобы сделать его match_constraint, используя android:layout_height="0dp"

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...