How can I get my application to redraw when the user hides the navigation bar on Samsung S9

I have a Xamarin.Forms application, which fails to redraw, when the user hides the navigation bar on Samsung S9 (and probably S8 as well). All I get is an empty white space where the navigation bar used to be.

The attached images, showing the bottom of the screen, demonstrate what I see before and after hiding the navigation bar.


Is there any way for my application to respond and redraw the screen to utilise the extra space left by the navigation bar?

Best Answer

  • Accepted Answer

    It turns out that the application I was working on was using code based on Michael Dimoudis's solution to "tame" the keyboard on Android.

    This solution selectively modifies the height of the root view as the soft keyboard appears and disappears. It turns out that it was too selective for my needs and I modified the code to always update the height if the available height changes.

    For others using Michael's solution and/or interested in my modifications, I changed the method PossiblyResizeChildOfContent to read:

        private void PossiblyResizeChildOfContent()
        {
            var usableHeightNow = this.ComputeUsableHeight();
            if (usableHeightNow != this.usableHeightPrevious)
            {
                this.frameLayoutParams.Height = usableHeightNow;
                this.mChildOfContent.RequestLayout();
                this.usableHeightPrevious = usableHeightNow;
            }
        }
    

    I hope this helps someone with similar issues.

Answers

  • Note that the app's splash screen uses the whole screen, whereas pages within the app leave an empty space where the navigation bar would be.

  • GudjonGudjonsson.9310GudjonGudjonsson.9310 USMember ✭✭
    Accepted Answer

    It turns out that the application I was working on was using code based on Michael Dimoudis's solution to "tame" the keyboard on Android.

    This solution selectively modifies the height of the root view as the soft keyboard appears and disappears. It turns out that it was too selective for my needs and I modified the code to always update the height if the available height changes.

    For others using Michael's solution and/or interested in my modifications, I changed the method PossiblyResizeChildOfContent to read:

        private void PossiblyResizeChildOfContent()
        {
            var usableHeightNow = this.ComputeUsableHeight();
            if (usableHeightNow != this.usableHeightPrevious)
            {
                this.frameLayoutParams.Height = usableHeightNow;
                this.mChildOfContent.RequestLayout();
                this.usableHeightPrevious = usableHeightNow;
            }
        }
    

    I hope this helps someone with similar issues.

Sign In or Register to comment.