Arvind Chourasiya
Arvind Chourasiya

Reputation: 17422

NavigationPage.Icon, adding tab icon for android xamarin.forms

My code showing icon only for iOS application. How can I add tab icon in NavigationPage.Icon for android too, xaml code

<NavigationPage Title="DairyTabPage">
    <NavigationPage.Icon>
        <OnPlatform x:TypeArguments="FileImageSource">
            <On Platform="iOS" Value="icon_tab"/>          
        </OnPlatform>
    </NavigationPage.Icon>
    <x:Arguments>
        <local:HomePage />
    </x:Arguments>
</NavigationPage>

Upvotes: 0

Views: 1739

Answers (2)

Miklos Kanyo
Miklos Kanyo

Reputation: 196

This is what worked for me in case the other answer doesn't work for you:

            <NavigationPage Title="Title">
                <NavigationPage.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource">
                        <On Platform="iOS" Value="tab_feed.png"/>
                        <On Platform="Android" Value="tab_feed"/>
                    </OnPlatform>
                </NavigationPage.Icon>
                <x:Arguments>
                    <views:ItemsPage />
                </x:Arguments>
            </NavigationPage>

Where I have put "tab_feed.png" into /Resources/drawable/tab_feed.png and included in the .Android project and rebuilt it so it regenerated the Resource.designer.cs file.

Upvotes: 0

Arvind Chourasiya
Arvind Chourasiya

Reputation: 17422

<NavigationPage Title="DairyTabPage" Icon="icon_tab">
    <x:Arguments>
        <local:HomePage />
    </x:Arguments>
</NavigationPage>

Upvotes: 2

Related Questions