Android Toolbar height in Xamarin.Forms

Does anyone know how to get the toolbar height in Xamarin.Forms on Android?

Answers

  • MuhammadhamzaMuhammadhamza USMember ✭✭
    edited January 2018
        <?xml version="1.0" encoding="utf-8" ?>
        <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                     x:Class="AdvOSS.ConfigurationPages.AdvancedSettingsPage"
                     xmlns:CustomTemplate="clr-namespace:AdvOSS.CutomizeDataTemplates.CustomizeSelector;assembly=AdvOSS"
                     NavigationPage.HasNavigationBar="False"
                     BackgroundColor="WhiteSmoke"
                     >
    
         <ContentPage.Resources>
                <ResourceDictionary>
                    <Style x:Key="ToolBarButton" TargetType="Button">
                        <Setter Property="BackgroundColor" Value="#2B6583"/>
                        <Setter Property="TextColor" Value="#cccccc" />
                        <Setter Property="HorizontalOptions" Value="FillAndExpand" />
                        <Setter Property="VerticalOptions" Value="FillAndExpand" />
                        <Setter Property="BorderRadius" Value="0" />
                        <Setter Property="FontSize" Value="12" />
                        <Setter Property="FontAttributes" Value="Bold" />
                    </Style>
                    <Style x:Key="ToolBarLabel" TargetType="Label">
                        <Setter Property="BackgroundColor" Value="#2B6583"/>
                        <Setter Property="TextColor" Value="White" />
                        <Setter Property="HorizontalOptions" Value="CenterAndExpand" />
                        <Setter Property="VerticalOptions" Value="CenterAndExpand" />
                        <Setter Property="VerticalTextAlignment" Value="Center" />
                        <Setter Property="HorizontalTextAlignment" Value="Center" />
                        <Setter Property="FontSize" Value="15" />
                        <Setter Property="FontAttributes" Value="Bold" />
                    </Style>
                    <Style x:Key="ToolBarBoxView" TargetType="BoxView">
                        <Setter Property="BackgroundColor" Value="#2B6583"/>
                        <Setter Property="HorizontalOptions" Value="FillAndExpand" />
                        <Setter Property="VerticalOptions" Value="FillAndExpand" />
                    </Style>
                </ResourceDictionary>
            </ContentPage.Resources>
    
         <ContentPage.Content>
                <StackLayout Spacing="10" BackgroundColor="WhiteSmoke">
                    <Grid Grid.Row="0" Grid.ColumnSpan="3"  ColumnSpacing="0" RowSpacing="0" x:Name="SearchGrid"  Padding="0,0,0,0" Margin="0,0,0,0" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="50"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*"/>
                            <ColumnDefinition Width="5*"/>
                            <ColumnDefinition Width="1*"/>
                        </Grid.ColumnDefinitions>
    
                        <BoxView    Grid.Row="0" Grid.ColumnSpan="3"   Style="{StaticResource ToolBarBoxView}" />
                        <Label      Grid.Row="0" Grid.ColumnSpan="3"   Style="{StaticResource ToolBarLabel}"   Text="Advanced Settings" />
                        <Button     Grid.Row="0" Grid.Column="0"       Style="{StaticResource ToolBarButton}"  Clicked="BackClicked"  Image="uf_Backbutton.png"/>
                    </Grid>
        <StackLayout>
    
        //content view
    
         </StackLayout>
                </StackLayout>
            </ContentPage.Content>
        </ContentPage>
    
    
    ``Device.BeginInvokeOnMainThread(()=> App.Current.MainPage = new NavigationPage(new AdvancedSettingsPage()));
    
Sign In or Register to comment.