工具栏没有完全显示

Toolbar does not show completely

我在我的项目中使用来自 ToolBar 的波纹管,当我从 Toolbar 中删除 app:layout_constraintTop_toTopOf="parent" 时效果很好,但是 RecyclerView 覆盖在 [=14= 上] 当我添加它时 ToolBar 显示了一半:

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbarCourses"
        style="@style/CustomToolbar"
        android:background="@color/biscay"
        app:layout_constraintBottom_toTopOf="@+id/swpCourses"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_scrollFlags="scroll|enterAlways">

    </androidx.appcompat.widget.Toolbar>

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swpCourses"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbarCourses">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rcvCourses"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </androidx.recyclerview.widget.RecyclerView>
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

这里是 ToolBarstyle

<style name="CustomToolbar">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">?android:attr/actionBarSize</item>
</style>

但请向我展示 toolBar 如下所示,不要展示完整的 toolbar

对于 SwipeRefreshLayout 设置:

    android:layout_width="0dp"
    android:layout_height="0dp"

约束更重要,所以布局宽度和高度应该是0dp。

完整代码:

<androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbarCourses"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        android:background="@color/colorAccent"
        app:layout_constraintBottom_toTopOf="@+id/swpCourses"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_scrollFlags="scroll|enterAlways">

</androidx.appcompat.widget.Toolbar>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swpCourses"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbarCourses">

    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rcvCourses"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    </androidx.recyclerview.widget.RecyclerView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>