NavigationBar not hide in Immersive Mode when show a DialogFragment with Navigation Component-Android Kotlin

51 views Asked by At

I'm a newbie and created a game on native Android with Kotlin (a big mistake).

https://play.google.com/store/apps/details?id=nochi.words

Since I believed it, I have had nothing but problems. And the problem I have that I cannot solve is hiding the Navigation Bar when I show a DialogFragment when i use Immersive Mode.

Game

Show DialogFragment with Navigation Gesture

Show DialogFragment with Navigation Buttons

I use the Navigation Component to display the DialogFragment. It seems like no one on the internet is having the same problem or am I missing something.

game_graph.xml
...
<dialog
        android:id="@+id/settingsFragment"
        android:name="nochi.words.ui.SettingsFragment"
        android:label="fragment_settings"
        tools:layout="@layout/fragment_settings" >
</dialog>
...

This solution doesn't work for me because when I click on the DialogFragment it appears again: Hide system navigation bar when show DialogFragment

I'm thinking about switching to Unity if I can't solve it.

1

There are 1 answers

0
R.Lin On BEST ANSWER

Due to the lack of function code from description above, I don't know how you display or implement the DialogFragment.

For immersive mode, you can hide navigation bar by hiding system bars:

val windowInsetsController =
  WindowCompat.getWindowInsetsController(your_window, your_window.decorView)

// Hide the system bars.
windowInsetsController.hide(Type.systemBars())
  • Use Type.navigationBars() to hide only the navigation bar.

Hope this is working for you.

Related Android documents:

If this answer not working, please provide more info of your code for others to clarify the problem. Good luck!