Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide Android ActionBar in Xamarin.Forms?

How can I hide the ActionBar of an Activity in Xamarin.Forms? I tried the following but none of it worked:

  • calling ActionBar.Hide() in OnCreate()
  • setting the theme to "@android:style/Theme.Holo.Light.NoActionBar"
like image 414
kaolick Avatar asked Oct 27 '14 14:10

kaolick


2 Answers

you can just hide it in your constructor

public partial class MyPage : ContentPage
{
    public MyPage()
    {
        NavigationPage.SetHasNavigationBar(this, false);
        InitializeComponent();            
    }        
}
like image 136
ahaliav fox Avatar answered Sep 23 '22 17:09

ahaliav fox


Just found the solution parallel to @Pete. It seems that this is a bug under Xamarin.Forms at the moment.

I added this in my Styles.xml and set the theme to my Activity:

<?xml version="1.0" encoding="UTF-8" ?>
<resources> 
    <style name="NoActionBarTheme" parent="android:Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/invisible_action_bar_style</item>
    </style>
    <style name="invisible_action_bar_style" parent="android:Widget.Holo.ActionBar">
        <item name="android:height">0dp</item>
    </style>

</resources>
like image 43
kaolick Avatar answered Sep 26 '22 17:09

kaolick