Hello,
I try to use an icon instead of the title on the main page of my Xamarin.Forms app.
I've read a lot of related topics, but I didn't found any solution:
navigationpage-settitleicon
navigationpage-settitleicon-works-on-ios-but-not-android
toolbar-title-set-center-align
xamarin-forms-custom-toolbar-android
On iOS this is done easily by adding this on my first page:
NavigationPage.SetTitleIcon(this, "navbar_logo.png");
On Android, I've added this on Toolbar.axml:
<ImageView android:src="@drawable/navbar_adp_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" />
This works, but the icon is now visible on each page on Android.
I've tried to use a renderer to hide the icon when I navigate to another page. For this I would like to use the override OnViewAdded() method:
public class CustomNavigationPageRenderer : NavigationPageRenderer { public override void OnViewAdded(Android.Views.View child) { ... } }
But I can't cast the child into Xamarin.Forms.Platform.Android.PageContainer, cause this object is "internal".
So I don't see how I could achieve this...
Would you have any suggestion?