当用户处于登录片段(或注册片段)时,如何禁用导航抽屉以及汉堡包按钮和工具栏?用户登录应用程序后,我想启用导航抽屉和其他功能。
activity_main.xml
<com.google.android.material.appbar.AppBarLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/materialToolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
app:navigationIcon="@drawable/menu_sandwich_button" />
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view_menu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/menu_header"
app:menu="@menu/menu">
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
onCreate()
setSupportActionBar(materialToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
您可以像这样禁用它:
navDrawer.close();
nawDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);