Gibt es eine Möglichkeit, Action Bar von Xamarin Forms - Portable (Xaml) in Android zu entfernen?
Ich möchte weniger als ein Zeichen ("<") und das Anwendungssymbol entfernen, das über der Inhaltsseite von Xamarin Forms xaml angezeigt wird.
Sie können die Navigationsleiste von Xaml mithilfe von Xamarin.Forms mithilfe des folgenden Codes entfernen.
NavigationPage.SetHasNavigationBar (this, false);
Wobei this
für die aktuelle Seiten-/Formularinstanz steht.
Hoffe das hilft!
NavigationPage.SetHasNavigationBar(this, false);
Das oben Genannte ist nicht die gute Lösung.
Mit diesem Code wird die auf der Seite vorhandene NavigationBar
deaktiviert.
Wir können die echte Lösung nur erreichen, indem wir eine NavigationRenderer
für NavigationPage
für Android
erstellen.
void RemoveAppIconFromActionBar()
{
var actionBar = ((Activity)Context).ActionBar;
actionBar.SetIcon (new ColorDrawable (Color.Transparent.ToAndroid ()));
}
Den vollständigen Codeausschnitt finden Sie im Github: https://Gist.github.com/Vaikesh/f86d1968c8166519f102#file-customnavigationrenderer-cs
In der Aktionsleiste ist die Schaltfläche "Zurück" verfügbar. Sie können es mit entfernen
NavigationPage.SetHasBackButton(this, false)
Der beste Weg, dies von einer XML-Seite aus zu erreichen
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="ICLDC.Digital.General.Pages.AboutApp.AboutApplication"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.Microsoft.com/winfx/2009/xaml"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;Assembly=Xamarin.Forms.Core"
xmlns:local="clr-namespace:ICLDC.Digital.General.Pages.Generic"
xmlns:translate="clr-namespace:ICLDC.Digital.General.Helpers"
ios:Page.UseSafeArea="True"
NavigationPage.HasNavigationBar="False">
<ContentPage.Content>
<StackLayout
BackgroundColor="White"
HorizontalOptions="FillAndExpand"
Spacing="0"
VerticalOptions="FillAndExpand"/>
</ContentPage.Content>
</ContentPage>
Der einfachste Weg, dies zu erreichen, ist das Hinzufügen von NavigationPage.HasNavigationBar = "false" in Ihrer ContentPage
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.Microsoft.com/winfx/2009/xaml"
x:Class="SterlingSwitch.Pages.Page1"
NavigationPage.HasNavigationBar="False">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>