Chu*_*uck 1 navigation android uinavigationcontroller
使用Navigation Drawer Activity 创建新项目后,构建并运行,该Activity 不起作用。它有许多片段,当从活动抽屉中选择它们时,它们应该更改为。打开抽屉,选择选择,只见:这是家片段。
在网上搜索了2个小时,答案不清楚。DrawerLayout 的 Z 顺序
我只是希望模板在您运行时能够实际工作。
Chu*_*uck 14
因此,只是为了让导航抽屉活动(新的模板...您可以从中创建一个新项目)工作,您必须通过移动
<include
layout="@layout/app_bar_main"
Run Code Online (Sandbox Code Playgroud)
以上
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
Run Code Online (Sandbox Code Playgroud)
然后,该程序将运行,您可以从那里继续。
所以改变:
<?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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.drawerlayout.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
到
<?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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我希望这能帮助那些没有我做那么多时间的人。这里的教训是:仅仅因为开发人员提供了一个模板,并不意味着它可以正常工作。所以不要自动认为程序不工作是你的错。
| 归档时间: |
|
| 查看次数: |
3038 次 |
| 最近记录: |