Title icon of page is not showing

Ajay87Ajay87 INMember ✭✭

Title icon of a page is not showing in android, how can i resolve it please help.

Best Answer

  • JarvanJarvan Xamurai
    edited June 13 Accepted Answer

    @Ajay87
    Create a TitleView to display the image in Navigation Bar.
    Tutorial: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/hierarchical#displaying-views-in-the-navigation-bar

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 BackgroundColor="Blue"
                 x:Name="page"
                 x:Class="App10.Page2">
        <NavigationPage.TitleView>
            <StackLayout Orientation="Horizontal">
                <Image Source="grid_.png" WidthRequest="35"/>
                <Label Text="page2" VerticalOptions="Center"/>
            </StackLayout>
        </NavigationPage.TitleView>
    
        <ContentPage.Content>
            <StackLayout>
    
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>
    

Answers

  • BASHABASHA USMember ✭✭

    If you are using prism with Mvvm this is how it will be

                        var param = new NavigationParameters();
    
                        param.Add("Icon", "homeIcon");
                        param.Add("Title", "Home Page");
                        param.Add("Pagename", nameof(HomePage));
                        await _navigationServices.NavigateAsync("/MenuPage/NavigationPage/HomePage", param);
    
  • Ajay87Ajay87 INMember ✭✭

    @BASHA
    Thanks for reply, let me try

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited June 13

    @Ajay87
    You can add the icon in App.Android Toolbar.axml.

    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:popupTheme="@style/ThemeOverlay.AppCompat.Light">
    
        <ImageView 
            android:src="@drawable/gri_d"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    
    </android.support.v7.widget.Toolbar>
    

    Refer to https://stackoverflow.com/a/40098078/11083277

  • Ajay87Ajay87 INMember ✭✭

    @yelinzh ,
    Hi yelinzh, actually i need to do in xamarin forms not in native platforms.

    Thanks 4 reply

  • nick5454nick5454 USUniversity ✭✭✭
    edited May 3

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml x:Class="MenuDrawerPage" ** Icon="Bars32.png"** BackgroundColor="#0057a5" Padding="0,40,0,0"

    Like that? @Ajay87

  • Ajay87Ajay87 INMember ✭✭
    edited May 8

    @nick5454 Hi nick,
    yes i tried, but its not working

  • nick5454nick5454 USUniversity ✭✭✭

    @Ajay87 Can you post your markup. Is this a master-detail, tabbed, single? Is this on the second page and if so and you have a Navigation page then like the answer above said, you would need a custom renderer.

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited June 13 Accepted Answer

    @Ajay87
    Create a TitleView to display the image in Navigation Bar.
    Tutorial: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/hierarchical#displaying-views-in-the-navigation-bar

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 BackgroundColor="Blue"
                 x:Name="page"
                 x:Class="App10.Page2">
        <NavigationPage.TitleView>
            <StackLayout Orientation="Horizontal">
                <Image Source="grid_.png" WidthRequest="35"/>
                <Label Text="page2" VerticalOptions="Center"/>
            </StackLayout>
        </NavigationPage.TitleView>
    
        <ContentPage.Content>
            <StackLayout>
    
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>
    
  • Ajay87Ajay87 INMember ✭✭

    @yelinzh
    Hi yelinzh,
    Its working
    Thanks

Sign In or Register to comment.