Home:ALL Converter>How to use android bottom sheet with android navigation component?

How to use android bottom sheet with android navigation component?

Ask Time:2019-09-28T06:20:40         Author:AndroLife

Json Formatter

I based my code on this question : How to create BottomSheetDialogFragment using Navigation Architecture Component?

I want to use fragment bottom sheet with navigation component I used the following setup :

 <fragment
        android:id="@+id/mainFragment"
        android:name="package.MainFragment"
        android:label="main_fragment"
        tools:layout="@layout/main_fragment" >
        <action
            android:id="@+id/action_mainFragment_to_bottomSheet"
            app:destination="@id/bottomSheet" />
    </fragment>

    <dialog
        android:id="@+id/bottomShee"
        android:name="package.OptionFragment" />

and in the code

view.findNavController().navigate(R.id.action_mainFragment_to_bottomSheet)

But the problem is that the bottom sheet appears in another fragment and not shadowing current fragment.

is there any way to implement bottom sheet with android navigation component?

Author:AndroLife,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58141866/how-to-use-android-bottom-sheet-with-android-navigation-component
yy