Skip to content

[Android] VisibleBoundsPadding.PaddingMask.Top does not always work as intended #6218

Closed

Description

@takla21

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?

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/tbd
    platform/android 🤖
    on Jun 10, 2021
  2. added
    difficulty/starter 🚀
    project/layout 🧱
    good first issue
    and removed
    difficulty/tbd
    triage/untriaged
    on Jun 10, 2021
  3. jeromelaban commented on Jun 10, 2021

    @jeromelaban
    Member

    The computation is supposed to use the status bar size to set the ApplicationView.VisibleBounds property:

    var visibleBounds = CalculateVisibleBounds(statusBarSizeExcluded);
    var trueVisibleBounds = CalculateVisibleBounds(statusBarSize);
    ApplicationView.GetForCurrentView()?.SetVisibleBounds(visibleBounds);
    ApplicationView.GetForCurrentView()?.SetTrueVisibleBounds(trueVisibleBounds);

    Could be the computation is done too early or not using the same content from occluded area.

  4. Youssef1313 commented on Aug 18, 2021

    @Youssef1313
    Member

    My best guess is that what stated in this comment isn't actually working:

    // The real metrics excluded the StatusBar only if it is plain.
    // We want to subtract it if it is translucent. Otherwise, it will be like we subtract it twice.

    Nothing gets subtracted when android:windowTranslucentStatus is false.

    @davidjohnoliver Since you worked on a similar issue in #4352, would you be able to help where/how to investigate?

  5. davidjohnoliver commented on Aug 20, 2021

    @davidjohnoliver
    Contributor

    @Youssef1313 This is the 'where', indeed. :)

    The point of the comment, IIRC, is that the native metrics returned by Android are different depending if the status bar is opaque or translucent. Accordingly we don't to 'double dip' in certain parts of the math by subtracting it twice. But clearly if the VisibleBounds is not taking the translucent status bar into account then the logic is faulty somewhere.

  6. rafaelrmoukc commented on Jun 2, 2022

    @rafaelrmoukc
    Contributor

    Start work on that issue, error still repro.

  7. 21 remaining items

  8. Lee31416 commented on Jan 29, 2025

    @Lee31416

    I still get this issue on uno "5.6.20" which is the latest when I updated today. I have a sample but for some reason I can't paste it here, but Kevin's issue still holds true with the android translucent flag and his workaround also still works althought it's not ideal

  9. jeromelaban commented on Feb 4, 2025

    @jeromelaban
    Member

    @Lee31416 would you be able to try with SafeArea instead?

  10. Lee31416 commented on Feb 5, 2025

    @Lee31416

    @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

  11. self-assigned this
    on Feb 7, 2025
  12. removed
    good first issue
    on Feb 10, 2025
  13. Lee31416 commented on Feb 11, 2025

    @Lee31416

    @jeromelaban which version of uno will contain the fix ?

  14. jeromelaban commented on Feb 11, 2025

    @jeromelaban
    Member

    @Lee31416 it should be an upcoming 5.6 service release, but there's an additional update coming in #19501

  15. github-actions commented on May 7, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.

  16. locked as resolved and limited conversation to collaborators on May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

difficulty/starter 🚀kind/bugplatform/android 🤖project/layout 🧱

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions