NavigationPage Bar Height unter Android

Diese plattformspezifische Android-Plattform legt die Höhe der Navigationsleiste auf einem .NavigationPage Sie wird in XAML verwendet, indem sie die NavigationPage.BarHeight bindungsfähige Eigenschaft auf einen ganzzahligen Wert festlegt:

<NavigationPage ...
                xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific.AppCompat;assembly=Xamarin.Forms.Core"
                android:NavigationPage.BarHeight="450">
    ...
</NavigationPage>

Alternativ kann sie mit der Fluent-API von C# genutzt werden:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific.AppCompat;
...

public class AndroidNavigationPageCS : Xamarin.Forms.NavigationPage
{
    public AndroidNavigationPageCS()
    {
        On<Android>().SetBarHeight(450);
    }
}

Die NavigationPage.On<Android> Methode gibt an, dass diese plattformspezifische App nur auf app compat Android ausgeführt wird. Die NavigationPage.SetBarHeight Methode im Xamarin.Forms.PlatformConfiguration.AndroidSpecific.AppCompat Namespace wird verwendet, um die Höhe der Navigationsleiste auf einem .NavigationPage Darüber hinaus kann die NavigationPage.GetBarHeight Methode verwendet werden, um die Höhe der Navigationsleiste in der NavigationPage.

Das Ergebnis ist, dass die Höhe der Navigationsleiste auf einem NavigationPage festgelegt werden kann:

NavigationPage-Navigationsleistenhöhe