【发布时间】:2021-08-13 21:44:54
【问题描述】:
我正在开发一个 Android 应用程序 (java),它目前只有一个活动 (MainActivity),它通过底部导航加载四个片段。我正在使用导航组件,这是 nav_graph:
<?xml version="1.0" encoding="utf-8"?>
<navigation 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/nav_graph"
app:startDestination="@id/homeFragment">
<fragment
android:id="@+id/homeFragment"
android:name="com.myapp.app.HomeFragment"
android:label="Home"
tools:layout="@layout/fragment_home">
// .. actions to sub fragments ..
</fragment>
<fragment
android:id="@+id/secondFragment"
android:name="com.myapp.app.SecondFragment"
android:label="Second"
tools:layout="@layout/fragment_second" />
// .. actions to sub fragments ..
<fragment
android:id="@+id/thirdFragment"
android:name="com.myapp.app.ThirdFragment"
android:label="Third"
tools:layout="@layout/fragment_third">
// .. actions to sub fragments ..
</fragment>
<fragment
android:id="@+id/fourthFragment"
android:name="com.myapp.app.FourthFragment"
android:label="Fourth"
tools:layout="@layout/fragment_fourth" >
// .. actions to sub fragments ..
</fragment>
// .. More subfragments linked from the first four ..
</navigation>
我希望有一个单独的流程,其中有一个入职屏幕,可以链接到登录或注册。登录或完成注册过程后,用户应返回带有底部导航的主页片段。问题是,整个第二个流程不应该显示工具栏或底部导航,它们应该是全屏的,并且不应该允许访问底部导航布局。
如何让底部导航只影响主应用中的那些片段,而不影响登录/注册过程中的屏幕?
【问题讨论】:
标签: android android-fragments android-navigation