Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add logo at the middle of Navigation bar?

I want to add a logo in the middle of the navigation bar like this:

<ContentPage.ToolbarItems>
   <ToolbarItem  Icon="logo.png" Activated="RefButtonClicked"></ToolbarItem>
</ContentPage.ToolbarItems>

I also tried this:

var cancelItem = new ToolbarItem
{
    Text = "Cancel",
    Icon = "tabalilogo.png",
    Order = ToolbarItemOrder.Secondary
};

Everything I tried positioned the logo on the right side of the navigation bar. How can I center it?

like image 904
Ahmed Sayed Avatar asked Feb 13 '17 17:02

Ahmed Sayed


People also ask

How do you put a logo in the middle of a nav bar?

So, in order to resolve this problem, we have assigned the display property of the image tag to “block” and then assign proper width and height to it. Assign the margin to “auto”. You will see that the logo image is now centered in the navigation bar.

How do I add an image to my navigation bar?

We just need to add a div tag with the class as a container and put the navbar-brand(image or logo) inside this div. After that, we just need to add the class mx-auto to the navbar-brand class.

How do you center a logo in HTML?

An <img> element is an inline element (display value of inline-block ). It can be easily centered by adding the text-align: center; CSS property to the parent element that contains it. To center an image using text-align: center; you must place the <img> inside of a block-level element such as a div .

How do I center align a logo in CSS?

To center an image, we have to set the value of margin-left and margin-right to auto and make it a block element by using the display: block; property. If the image is in the div element, then we can use the text-align: center; property for aligning the image to center in the div.


1 Answers

Recently After Updating to xamarin forms 3.2, You can customize the title bar using title bar property.

     <ContentPage>
<NavigationPage.TitleView>
    <StackLayout Orientation="Horizontal" VerticalOptions="Center" Spacing="10">
        <Image Source="iconXamagon.png">
            <Image.GestureRecognizers>
                <Image.TapGestureRecognizer
                    Tapped="HandleTapped" />
            </Image.GestureRecognizers>
        </Image>
        <Label Text="3.2.0" FontSize="16" TextColor="Black" VerticalTextAlignment="Center" />
    </StackLayout>
</NavigationPage.TitleView>
....

For more details https://blog.xamarin.com/xamarin-forms-3-2-0-released-going-big-with-little-things/

like image 107
Ahmed Sayed Avatar answered Sep 29 '22 05:09

Ahmed Sayed