【问题标题】:Android navigation component. Show full-screen dialog with morphing navigation icon from arrow to cross安卓导航组件。显示带有从箭头到十字的变形导航图标的全屏对话框
【发布时间】:2021-06-30 14:28:29
【问题描述】:

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

问题

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

我根据documentation 创建了对话框片段目标:
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" />

它以常规对话框开始(不是全屏)。我相信,导航组件支持材料设计建议,但我错过了如何启用所需行为的一个小细节。

【问题讨论】:

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


    【解决方案1】:
    1. 你可以在片段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。

    【讨论】:

    • 它没有解决我的问题。此示例无法使导航按钮从箭头变为十字
    • 如果没有解决,可以使用:添加片段。 FragmentTransaction 事务 = fragmentManager.beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.add(android.R.id.content, newFragment) .addToBackStack(null).commit()
    • 嗯。我需要自己编写和支持它。我正在从导航组件中寻找解决方案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-20
    • 2011-11-24
    • 1970-01-01
    相关资源
    最近更新 更多