I'm trying to have a full screen DialogFragment
with the ability to show / hide status and navigation bars when tapping the screen. Here is the DialogFragment
class FullScreenFragment : DialogFragment() {
override fun onCreate(savedStateInstance: Bundle?) {
super.onCreate(savedStateInstance)
setStyle(STYLE_NORMAL, R.style.Theme_FullScreenDialog)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = FragmentTemplateBinding.inflate(inflater, container, false)
return binding.root
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
activity?.window?.decorView?.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE)
}
}
And the related theme is,
<style name="Theme.FullScreenDialog" parent="Theme.MaterialComponents.Dialog">
<item name="windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:fitsSystemWindows">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:textColor">@android:color/white</item>
</style>
Having done these steps, I can still see navigation bar. Status bar seems to be hiding. Any idea what could possibly be the issue?