Action bar height

Asher Cohen 1 Reputation point
2021-01-29T15:16:24.177+00:00

How I can set the height of the action bar

The page is called from MasterDetailPage

<?xml version="1.0" encoding="utf-8" ?>  
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"  
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
             x:Class="BooksA.FirstPage">  
  
    <!--<NavigationPage.HasNavigationBar>  
        <OnPlatform ></OnPlatform>  
    </NavigationPage.HasNavigationBar>-->  
      
    <MasterDetailPage.Master >  
        <ContentPage Title="Master">  
              
            <ContentPage.Content >  
                <StackLayout>  
                      
                    <Label Text="תפריט"></Label>  
                    <Button x:Name="btnList" Clicked="btnList_Clicked" Text="רשימה"></Button>  
                    <Button x:Name="btnAdd" Clicked="btnAdd_Clicked" Text="הוסף"></Button>  
                    <Button x:Name="btnExport" Clicked="btnExport_Clicked" Text="יצוא"></Button>  
                    <Button x:Name="btnImport" Clicked="btnImport_Clicked" Text="יבוא"></Button>  
  
                </StackLayout>  
            </ContentPage.Content>  
  
             
        </ContentPage>  
  
         
    </MasterDetailPage.Master>  
  
      
      
    <MasterDetailPage.Detail >  
        <ContentPage Title="Detail" >  
            <ContentPage.Content>  
                <Label Text="MasterDetailPage.Detail"></Label>  
            </ContentPage.Content>  
        </ContentPage>  
    </MasterDetailPage.Detail>  
      
      
</MasterDetailPage>  

61903-bar.png

    <NavigationPage.TitleView   >  
          
          
  
        <Grid  >  
            <Grid.ColumnDefinitions>  
                <ColumnDefinition Width="*"/>  
                <ColumnDefinition Width="Auto"/>  
            </Grid.ColumnDefinitions>  
  
  
  
            <Label Text="ספרים"  Grid.Column="0" Grid.Row="0" TextColor="White" FontSize="Large" VerticalOptions="Center" HorizontalOptions="Start"></Label>  
  
            <StackLayout Grid.Column="1" Grid.Row="0" Style="{x:Null}" HorizontalOptions="EndAndExpand" Orientation="Horizontal" Margin="0,0,5,0">  
  
                <Button x:Name="butAdd" Clicked="butAdd_Clicked" Text="הוסף" BackgroundColor="DodgerBlue" BorderColor="DodgerBlue" TextColor="White" FontSize="20"></Button>  
  
  
  
                <Button x:Name="butSort" Clicked="butSort_Clicked" Text="מיון" BackgroundColor="DodgerBlue" BorderColor="DodgerBlue" TextColor="White" FontSize="20"></Button>  
  
            </StackLayout>  
        </Grid>  
  
    </NavigationPage.TitleView>  
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,310 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JessieZhang-MSFT 7,706 Reputation points Microsoft Vendor
    2021-01-30T08:44:27.69+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    From document MasterDetailPage Class,we could find that MasterDetailPage is obsolete as of version 5.0.0. Please use FlyoutPage instead. So, you can try FlyoutPage .
    For more details, you can check: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/flyoutpage

    How I can set the height of the action bar

    For android, you can check document NavigationPage Bar Height on Android:
    This Android platform-specific sets the height of the navigation bar on a NavigationPage. It's consumed in XAML by setting the NavigationPage.BarHeight bindable property to an integer value:

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

    In Ios, you can hide the default NavigationBar in that page and add a custom NavigationBar there, then you can set any height you want to the custom NavigationBar.

    In the Page, hide the default NavigationBar:

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

    And then add your custom NavigationBar.

    If you want to change the height of all the navigationBar in your project, you can have a basePage with custom NavigationPage there.

    For more details, you can check: https://stackoverflow.com/questions/61784782/change-navigation-bar-height-on-ios-xamarin-forms

    Best Regards,

    Jessie Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.