Advertisement

[记录]Navigation无title注意事项

阅读量:

该某个activity需实现全屏显示或去除其导航栏,并自定义一个无标题的主题;同时可在该activity对应的配置文件中进行主题样式配置

android:theme="@style/NoTitle"

然而,在Android Studio中为新的Bottom Navigation Activity项目进行Navigation设计时,则需要特别注意...

为了使Android Studio自动生成的Navigation工程实现Notitle功能,则需要修改两个地方。其中一项是,在 mobile Navigation.xml文件中创建一个fragment,并且删除 android:label 属性。另一项是,在Activity中设置该fragment为标题项,并将相关的属性设为不可见。

复制代码
    <fragment
    android:id="@+id/navigation_home"
    android:label="HomeFragment"  //remove this line
    android:name="com.shiwei.fly.ui.home.HomeFragment" />

二是,在MainActivity中注释掉下面两句:

复制代码
    // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        /*val appBarConfiguration = AppBarConfiguration(setOf(
                R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications))
        setupActionBarWithNavController(navController, appBarConfiguration)*/

当然,其实只修改二就可以了。

全部评论 (0)

还没有任何评论哟~