Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 398 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
android.view.View.systemUiVisibility deprecated. What is the replacement?

#11
If you are using **Jetpack Compose**, use this method in `setContent`:

```kt
@Composable
fun HideSystemUi()
{
val systemUiController = rememberSystemUiController()

SideEffect {
systemUiController.isSystemBarsVisible = false
}
}
```

Do not forget to add this to your app's `build.gradle` file (adjust the version if necessary):
```gradle
implementation "com.google.accompanist:accompanist-systemuicontroller:0.17.0"
```

The documentation can be found [here][2], although you might want to have a look at the [sources][1].


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#12
Here is a straight forward solution that works for all android version and hides the status bar

WindowInsetsControllerCompat(window, window.decorView).hide(WindowInsetsCompat.Type.systemBars())

It works well on emulators but sometimes on a real device if the keyboard pops up the status bar is shown again.
If you don't really need to hide/show the status bar programmatically then just add window full screen as an item to the theme you will use for that screen. For example you can create a style in theme.xml

<style name="HideStatusBar" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- hides status bar-->
<item name="android:windowFullscreen">true</item>
</style>

and in the AndroidManifest.xml you add a style to that activity section

<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
<!-- The style-->
android:theme="@style/NoactionBar"
android:exported="true" />

This also works for all version

Reply

#13
use this :
window.setDecorFitsSystemWindows(false)

Make sure that you have android build gradle setup that has minsdk of 30
Reply

#14
In the Styles file add two items:

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

And in activity file before `setContentView(R.layout.activity_main)` this following lines :

try {
actionBar!!.hide();
} catch (e:Exception){

}

Reply

#15
**JAVA**
```
private void showSystemUI() {
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
new WindowInsetsControllerCompat(getWindow(), yourRootView).show(WindowInsetsCompat.Type.systemBars());
}

private void hideSystemUI() {
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
WindowInsetsControllerCompat controller = new WindowInsetsControllerCompat(getWindow(), yourRootView);
controller.hide(WindowInsetsCompat.Type.systemBars());
controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
```
Reply

#16
**2022 Offical Solution with Kotlin Code:**


val windowInsetsController =
ViewCompat.getWindowInsetsController(window.decorView) ?: return
// Configure the behavior of the hidden system bars
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
// Hide both the status bar and the navigation bar
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())


Source:

[To see links please register here]

Reply

#17
For anyone looking to do this in Xamarin Forms and C#, I have added this code in the MainActivity class in the MainActivity.cs file:

```
private void SetWindowLayout()
{
if (Window != null) {
if (Build.VERSION.SdkInt >= BuildVersionCodes.R) {
IWindowInsetsController wicController = Window.InsetsController;


Window.SetDecorFitsSystemWindows(false);
Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

if (wicController != null) {
wicController.Hide(WindowInsets.Type.Ime ());
wicController.Hide(WindowInsets.Type.NavigationBars());
}
}
else {
#pragma warning disable CS0618

Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

Window.DecorView.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.Fullscreen |
SystemUiFlags.HideNavigation |
SystemUiFlags.Immersive |
SystemUiFlags.ImmersiveSticky |
SystemUiFlags.LayoutHideNavigation |
SystemUiFlags.LayoutStable |
SystemUiFlags.LowProfile);
#pragma warning restore CS0618
}
}
}
```

Then, in the OnCreate overridden method make a call to SetWindowLayout()

Then, override the OnWindowFocusChanged() method:

```
public override void OnWindowFocusChanged(
Boolean bHasFocus)
{
base.OnWindowFocusChanged(bHasFocus);

if (bHasFocus)
SetWindowLayout();
}
```

I hope this helps everyone in Visual Studio.

Loz.
Reply

#18
Java version:

playerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Document recommendation (respectively):



1. Low profile mode is deprecated. Hide the system bars instead

1. Use WindowInsetsController#hide(int) with Type#statusBars()

1. Use WindowInsets#getInsetsIgnoringVisibility(int)

1. Use WindowInsetsController#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

1. Use Window#setDecorFitsSystemWindows(boolean) with false.

1. Use WindowInsetsController#hide(int) with Type#navigationBars()

So, the final code is:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);

playerView.getWindowInsetsController()
.hide(WindowInsets.Type.systemBars()
| WindowInsets.Type.statusBars()
| WindowInsets.Type.navigationBars());

playerView.getWindowInsetsController()
.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);

playerView.getRootWindowInsets()
.getInsetsIgnoringVisibility(WindowInsets.Type.statusBars()
| WindowInsets.Type.navigationBars());

}else {
playerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
Reply

#19
For Android 11+ devices, and with the method `hide(WindowInsets.Type.systemBars()`, I get a problem when a popup is dynamically displayed. The navigation bar becomes visible and the background window is reduced. When the popup is closed, the navigation bar becomes hidden again and the background window is maximized.

With the method

`setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)`

previously used, there was no problem.
Reply

#20
<style name="Theme.MobileCredentialsAndroidSample"
parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowFullscreen">true</item>
...

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through