我从示例“抽屉导航 Activity ”创建了项目。导航图标适用于顶级和其他目的地。导航图标从“汉堡包”变为“箭头”并返回。
问题
好的。现在我需要实现全屏对话框 recommended用于带有键盘输入的对话框。
我根据 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 设计建议,但我遗漏了如何启用所需行为的微小细节。
最佳答案
- 您可以在 fragment
attach()
中隐藏/显示工具栏并在detach()
中显示
override fun onAttach(context: Context) {
super.onAttach(context)
(activity as? MainActivity)?.run {
goneBottomNavigation()
setStatusBarColor(R.color.C_E6EBEF)
}
}
- 这:导航组件也有同样的问题:How to hide toolbar in start destination .
关于安卓导航组件。显示全屏对话框,导航图标从箭头变为十字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66940961/