安卓导航组件。显示全屏对话框,导航图标从箭头变为十字

标签 android android-architecture-components android-architecture-navigation android-navigation android-jetpack-navigation

我从示例“抽屉导航 Activity ”创建了项目。导航图标适用于顶级和其他目的地。导航图标从“汉堡包”变为“箭头”并返回。

enter image description here

问题

好的。现在我需要实现全屏对话框 recommended用于带有键盘输入的对话框。

enter image description here

我根据 documentation 创建了对话框 fragment 目标:
ProductCountChangeFragment.kt

internal class ProductCountChangeFragment : DialogFragment(R.layout.product_count_change_fragment) {
    //...
}

navigation.xml

<dialog
    android:id="@+id/product_count_change_dialog_fragment"
    android:name="my.package.ProductCountChangeFragment"
    tools:layout="@layout/product_count_change_fragment" />

它以常规对话框(非全屏)开始。我相信,导航组件支持 Material 设计建议,但我遗漏了如何启用所需行为的微小细节。

最佳答案

  1. 您可以在 fragment attach() 中隐藏/显示工具栏并在 detach() 中显示
override fun onAttach(context: Context) {
    super.onAttach(context)
    (activity as? MainActivity)?.run {
        goneBottomNavigation()
        setStatusBarColor(R.color.C_E6EBEF)    
    }   
}
  1. 这:导航组件也有同样的问题:How to hide toolbar in start destination .

关于安卓导航组件。显示全屏对话框,导航图标从箭头变为十字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66940961/

相关文章:

android - ViewModel发出多次而不是一次发出

java - 这个 Android 相机设置叫什么?如何设置它?

android - 在按钮上单击切换 xml 布局页面

kotlin 中的 Android ViewModelProviderFactory

android - 房间删除​​查询不会删除数据库中的行

android - 带有导航组件的 startDestination 中的按钮返回

android - 使用导航组件将不同菜单与不同 fragment 绑定(bind)

android - 用于精细导航的免费 SDK

android - 如何仅在高于特定声级时才录制音频?

android - 如何在没有 ActionBar 的 AndroidX 中设置 BottomNavigationView