Recycler视图将覆盖ToolbarMenu

问题描述 投票:0回答:3

Emulator Pic

这是我的Xml代码:-

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MainActivity"
    xmlns:android="http://schemas.android.com/apk/res/android">

<androidx.drawerlayout.widget.DrawerLayout
        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=".MainActivity"
        android:id="@+id/drawerLayout"
        android:fitsSystemWindows="true">

        <LinearLayout
            android:id="@+id/main_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <include
                android:id="@+id/toolbar1"
                layout="@layout/toolbar_standalone" />
        </LinearLayout>

        <!--    Navigation View Describe here input are header and toolbar-->
        <com.google.android.material.navigation.NavigationView
            android:id="@+id/navigationView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:headerLayout="@layout/navigation_header"
            app:itemIconTint="#8C000000"
            app:itemTextColor="#E6000000"
            app:menu="@menu/navigation_menu_items_grouped">

        </com.google.android.material.navigation.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>

    <!--recycler view add here-->
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp">
    </androidx.recyclerview.widget.RecyclerView>

</androidx.constraintlayout.widget.ConstraintLayout>

这里Recycler View在工具栏上方。工具栏未显示在“模拟器”屏幕中。回收站视图运行正常,但未显示工具栏及其菜单。请让我纠正布局以解决此问题。请让我知道对XML文件进行哪些更改。

android android-recyclerview navigation-drawer toolbar
3个回答
0
投票

您的RecyclerView有


0
投票

这是正确的答案,只是倒过来了。试试这个:


0
投票

这对我有用:-

© www.soinside.com 2019 - 2024. All rights reserved.