I have been trying to make a fragment fullscreen, but almost every answer on the web has deprecated methods. Even the android official site has a deprecated method Link.
I'm using kotlin and after following this answer, I have tried this in fragment.
override fun onAttach(context: Context) {
super.onAttach(context)
requireActivity().window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
}
override fun onDetach() {
super.onDetach()
requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
}
but the result that I got is this
You can clearly see navigation and status bars are still there.
Can you share the proper and latest way to get fullscreen in fragment?

If you read the docs for ViewCompat.getWindowInsetsController(), you'll see that it's only deprecated because they want you to use getInsetsController() instead. Otherwise, the sample code works just fine.