I want to achieve behaviour similar to video attached below from the WEBTOONS app, where content is in full screen and they hide and show status bar
I want to achieve this behaviour in API Level 23..to..31
What is the correct way to achieve this behaviour without using deprecated code ?
Thanks
I have tried multiple solutions as mentioned below but none of the gives the required behaviour and also few methods below are deprecated.
WindowManager.LayoutParams.FLAG_FULLSCREEN)
-> requireActivity().window.setFlags(LayoutParams.FLAG_LAYOUT_NO_LIMITS, LayoutParams.FLAG_LAYOUT_NO_LIMITS)
-> windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
-> requireActivity().window.setDecorFitsSystemWindows(false)
-> requireActivity().window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
UPDATE
I am able achieve the required behaviour only on Devices without notch using this code function
but fails for the devices with notch ,content wont get covered under status bar in full screen mode gives a black space in the status bar region
tried
tried method
but didn’t help
And also content resizes as I exit full screen mode content goes under visible status bar
Above code is deprecate in API level 30 appreciate if could share exact non-deprecated alternative code
UPDATE2
was able to find the solution for all android versionas mentioned here
for more details refer this answer
You need to set following flags for window
SYSTEM_UI_FLAG_LAYOUT_STABLE : This flag indicates that the application's stable content should appear behind the system bars (status bar and navigation bar). It allows your application to use the space normally occupied by the system bars so that your content doesn't resize when the system bars hide or show.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN : This flag indicates that the application wants to occupy the entire screen, including the space behind the system bars. When this flag is set, the content of your application can extend into the area normally reserved for the status bar at the top of the screen.
I hope it will work for your scenario