Xamarin Forms Android, hide title bar border

How can I hide the border from the title bar in Xamarin Android? I am using Xamarin Forms and the following code is used in MainActivity.cs to hide the rest of the title bar.

[Activity(Label = "", MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait)]
protected override void OnCreate(Bundle bundle)
    {

        this.RequestWindowFeature(WindowFeatures.ActionBarOverlay);

        base.OnCreate(bundle);



        //Transperent Action Bar 
        ActionBar.SetIcon(Android.Resource.Color.Transparent);
        ActionBar.SetBackgroundDrawable(new ColorDrawable(Color.ParseColor("#000000ff")));
        ActionBar.SetStackedBackgroundDrawable(new ColorDrawable(Color.ParseColor("#000000ff"))); 

        Xamarin.Forms.Forms.Init(this, bundle);

        SetPage(App.GetMainPage());
    }

      

+3


source to share


6 answers


It looks like I don't need to do anything in Android Project using the following code in xaml.cs. The OnAppearing method did the trick  //Hide Nav Bar NavigationPage.SetHasNavigationBar(this, false);



+4


source


Use this code

    protected override void OnCreate(Bundle bundle)
    {
        RequestWindowFeature(WindowFeatures.NoTitle);
        base.OnCreate(bundle);

      



and i hope that if it works for you

+3


source


I think you should be using Theme for this

[Activity(Label = "", MainLauncher = true, Theme="@android:style/Theme.Holo.Light.NoActionBar", ScreenOrientation = ScreenOrientation.Portrait)] 

      

Hope this helps you

+2


source


Just use your NavigationPage

    public HelloWorlPage()
    {
        InitializeComponent();
        NavigationPage.SetHasBackButton(this, false);
        NavigationPage.SetHasNavigationBar(this, false);
    }

      

+1


source


You can use this code in your styles.xml file in Droid Project. The main thing here is to set the height to 0 dp.

 <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="elevation">0dp</item>
 </style>

      

+1


source


Try this thread in your MainActivity.cs,

[Activity (Label = "XXX", 
    Theme = "@android:style/Theme.Holo.Light",
    WindowSoftInputMode = SoftInput.AdjustPan,
    ConfigurationChanges=global::Android.Content.PM.ConfigChanges.Orientation|global::Android.Content.PM.ConfigChanges.ScreenSize |
    global::Android.Content.PM.ConfigChanges.KeyboardHidden)]

      

0


source







All Articles