Reputation: 1236
Recently I upgraded my Xamarin project to all the latest DLLs. Now on the navigation bar an icon has appeared on Android (haven't looked at iOS yet). See generic icon:
After spending hours searching and prototyping code I still can't figure out how to change or get rid of the icon! Doing a recursive search for png files in my project finds no such image.
There is a method SetTitleIcon but that method doesn't do anything. Some people talk about a toolbar xaml file in the layout folder, but I have no such file.
I followed this tutorial: https://xamarinhelp.com/xamarin-forms-toolbar/ but can only add icons, it doesn't remove the default icon.
I found this demo project: https://developer.xamarin.com/samples/monodroid/Supportv7/AppCompat/Toolbar but that code is quite different from mine. Do I need to go that route?
Anyway, my main xaml file:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SharedMobile"
NavigationPage.HasNavigationBar="true"
x:Class="SharedMobile.MainPage">
<MasterDetailPage.Master>
<local:MainPageMaster x:Name="MasterPage" />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage BarBackgroundColor="#DCDCDC">
<x:Arguments>
<local:ActionProcessesPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
There is little to no mention anywhere else in the project of a navigation bar. I did try to add a NavigationPage.Icon under the Navigation Page. Nothing happened.
I only do Xamarin part-time is my excuse.
Upvotes: 1
Views: 421
Reputation: 86006
In MainActivity.cs
(in the Android project),
protected override void OnCreate(Bundle bundle)
{
...
ActionBar.SetIcon(null);
LoadApplication(new Forms.App());
}
Upvotes: 1
Reputation: 1236
One of the main reasons I post on Stack Overflow is often (for some reason) shortly after posting I will figure out or find the answer.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SharedMobile;assembly=MyApp.Mobile"
NavigationPage.TitleIcon="transparent.png"
x:Class="SharedMobile.ActionProcessesPage">
Upvotes: 2