0

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

Video of required behaviour

APP ref link

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

rkr33
  • 1
  • 2
  • Does this answer your question? [Android: show/hide status bar/power bar](https://stackoverflow.com/questions/8273186/android-show-hide-status-bar-power-bar) – Stanislav Bondar Jun 13 '23 at 05:06
  • @StanislavBondar this doesn’t help as per my requirement and also FLAG_FULLSCREEN flag is deprecated on Android version R(API lvl 30) onwards – rkr33 Jun 13 '23 at 06:31

2 Answers2

0

You need to set following flags for window

window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

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

hammad
  • 61
  • 2
-1

was able to find the solution for all android version as mentioned here for more details refer this answer

rkr33
  • 1
  • 2