工具栏未完全显示

问题描述 投票:-1回答:1

我正在ToolBar中使用波纹管,就像在我的项目中一样,当我从app:layout_constraintTop_toTopOf="parent"中删除Toolbar时,它很好用,但是RecyclerView覆盖在Toolbar上,而当我添加它时,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>

这里是styleToolBar

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

但是像波纹管一样显示toolBar,但不显示完整的toolbarenter image description here

android toolbar androidx
1个回答
1
投票
© www.soinside.com 2019 - 2024. All rights reserved.