ViewPager不占用可用空间Android约束布局

问题描述

您好,我有一个具有AppBar(toolbar)的布局,其后是TabLayout,其后是Viewpager和BottomNavigation视图,位于该布局的底部。我已经使用约束布局。 Viewpager不会占据Tablayout和BottomNavigation之间的所有可用空间,而是仅占据布局的顶部。我无法通过从底部导航布局顶部的任何位置滑动来滚动视图寻呼机。以下是使用的布局:
任何人都可以查看我的布局并让我知道解决方法

<?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"
    tools:context=".RayonActivity">


    <include android:id="@+id/app_bar_layout"
        layout="@layout/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/sliding_tabs"
        style="@style/tab_style"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/app_bar_layout" />

    <androidx.viewpager2.widget.ViewPager2
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toBottomOf="@+id/sliding_tabs"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/bottom_navigation_view"
        android:layout_width="0dp"
        android:layout_height="@dimen/bottom_nav_bar"
        style="@style/Widget.MaterialComponents.BottomNavigationView.Colored"
        app:itemTextColor="@color/cg_text_light"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:labelVisibilityMode="labeled"
        app:menu="@menu/bottom_navigation_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)