uno: [Android] `VisibleBoundsPadding.PaddingMask.Top` does not always work as intended

Current behavior

When I removed the status bar by adding those 4 lines in the style.xml

<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>

Applying VisibleBoundsPadding.PaddingMask.Top on top of my xaml, it won’t give enough space for the status bar and notch (if available)

Android image

*See workaround for expected result

Expected behavior

Expected result and Actual result should be mostly aligned vertically.

iOS image

How to reproduce it (as minimally and precisely as possible)

Download StatusBarPaddingMask.zip Deploy on Android

Workaround

To achieve similar result, I am able to retrieve the actual status bar height with StatusBar.GetForCurrentView().OccludedRect.Height. I am wondering if this should actually be used to calculate VisibleBoundsPadding.PaddingMask.Top

Environment

Nuget Package:

  • Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
  • Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
  • Uno.SourceGenerationTasks
  • Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
  • Other:

Nuget Package Version(s): 3.9.0-dev.6

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Skia
    • WPF
    • GTK (Linux)
    • Tizen
  • Windows
  • Build tasks
  • Solution Templates

IDE:

  • Visual Studio 2017 (version: )
  • Visual Studio 2019 (version: 16.8.4)
  • Visual Studio for Mac (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )
  • Visual Studio Code (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 28 (24 by maintainers)

Most upvoted comments

@jeromelaban I already tried that and most other workaround we had done before like VisibleBoundsPaddingMask, SafeArea.insets, the safearea control and nothing seems to work

@jeromelaban @iury-kc sorry, after a double check i add activity.Window.Attributes.Flags.HasFlag(WindowManagerFlags.DrawsSystemBarBackgrounds) on the code before update and on update source code that stay. That check solve the problem

Test 6216 and if both are solve i will implement TESTS

The window is not supposed to have a padding. The configuration of the app is done in such a way that the entirety of the screen is supposed to be used.

If the VisibleBounds is correct, then it may be an issue with the VisibleBoundsPadding itself: https://github.com/unoplatform/uno/blob/489be09cf3b5a227d72ce5efe5b1f79d98dd8f6e/src/Uno.UI/Behaviors/VisibleBoundsPadding.cs#L214

@rafaelrmoukc the issue here is about the computations made by the Window.VisibleBounds property. I would not be surprised that we’re not computing the size of the status bar here:

https://github.com/unoplatform/uno/blob/d59985ffb51895568c5aa7fbd02c9499071894fe/src/Uno.UI/UI/Xaml/Window.Android.cs#L105-L110

When android:windowDrawsSystemBarBackgrounds is set to true.

Can you validate the value of that property?

Start work on that issue, error still repro.