Reputation: 4857
How can I hide the ActionBar
of an Activity
in Xamarin.Forms
? I tried the following but none of it worked:
ActionBar.Hide()
in OnCreate()
"@android:style/Theme.Holo.Light.NoActionBar"
Upvotes: 7
Views: 10802
Reputation: 79
This simple fix worked for me. Change the line at the top of your Styles.xml file to look like this:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
To replace the line that looked like this:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
All you need do is change the word "Dark" to "No" in front of ActionBar. Search "Theme.MaterialComponents" for a list of Material Components that you can use.
Upvotes: 0
Reputation: 3032
The better way to hide the ActionBar with Xamarin.Forms:
global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);
Upvotes: 1
Reputation: 2247
you can just hide it in your constructor
public partial class MyPage : ContentPage
{
public MyPage()
{
NavigationPage.SetHasNavigationBar(this, false);
InitializeComponent();
}
}
Upvotes: 12
Reputation: 4857
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>
Upvotes: 4