Skip to content

Instantly share code, notes, and snippets.

@utkukutlu
Last active November 11, 2023 13:51
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save utkukutlu/bd2e37253e7184179d923321e3ea72c1 to your computer and use it in GitHub Desktop.
Save utkukutlu/bd2e37253e7184179d923321e3ea72c1 to your computer and use it in GitHub Desktop.
android navigation component add fragment instead of replace
Android Navigation Component Dialog Fragment
fun openTestDialogFragment(){
findNavController().navigate(
R.id.action_mainFragment_to_testDialogFragment
)
}
<fragment
android:id="@+id/mainFragment"
android:name="com.utkukutlu.MainFragment"
android:label="MainFragment">
<action
android:id="@+id/action_mainFragment_to_testDialogFragment"
app:destination="@id/testDialogFragment" />
</fragment>
<dialog
android:id="@+id/testDialogFragment"
android:name="com.utkukutlu.TestDialogFragment"
android:label="TestDialogFragment" >
</dialog>
<style name="FullScreenDialogStyle" parent="AppTheme">
<item name="android:windowFullscreen">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">false</item>
</style>
class TestDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(
DialogFragment.STYLE_NORMAL,
R.style.FullScreenDialogStyle
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment