由于实现了抽屉[重复],我无法使用我的屏幕>> [

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

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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"> <androidx.recyclerview.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/recyclerView" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" tools:listitem="@layout/row" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:id="@+id/addFabButton" app:fabSize="normal" android:layout_margin="16dp" app:elevation="6dp" app:backgroundTint="@color/colorPrimary" android:src="@drawable/ic_add_black_24dp" /> <androidx.drawerlayout.widget.DrawerLayout android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" /> <com.google.android.material.navigation.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" app:menu="@menu/nav_menu" android:layout_gravity="left" /> </androidx.drawerlayout.widget.DrawerLayout> </RelativeLayout>

activity_nav.xml:

<?xml version="1.0" encoding="utf-8"?> <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" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" /> <com.google.android.material.navigation.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" app:menu="@menu/nav_menu" android:layout_gravity="left" /> </androidx.drawerlayout.widget.DrawerLayout>
[我发现,如果我在

activity_nav

activity_main中都没有widget.DrawerLayoutNavigationView,则在运行抽屉时将不会显示抽屉。
任何帮助或提示将不胜感激!

我正在开发一个android studio项目,并且正在尝试实现侧面抽屉/导航来浏览应用程序中的所有页面。尽管我以为我可以使用它,但是当我运行它时,我可以将其滑开...

android android-studio android-layout android-fragments navigation-drawer
1个回答
0
投票
嗨,我认为您在设计布局时会感到困惑,以便更好地理解
© www.soinside.com 2019 - 2024. All rights reserved.