NavigationPage.SetTitleIcon is not working on Android with FormsAppCompatActivity

I am using Xamarin.Forms 2.3.0.107 (I think) and I'm trying to set an icon or image into the navigation bar like We have already on iOS. But it seems SetTitleIcon is not working or either ignoring this behavior on Android using AppCompat. I'm not expert on Android but it seems that on API 23+ is a "discourage using and icon + text in the toolbar..". Based on this, is there anyway to achieve this? I have already tried using a custom renderer on the page I am using the NavigationPage but setting the SupportActionBar.SetLogo or SetIcon doesn't work at all.

Please I would appreciate your answer...

Regards

Best Answer

Answers

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    Hi @codercampos
    I tried your solution, but this doesn't work for me:

    • the icon is well visible
    • but the title is still visible too

    Your CustomRenderer would have to remove it, isn't it?
    In add, do you know is there is a way to display the icon on a single page only?

  • codercamposcodercampos SVMember ✭✭
    edited August 2017

    @Pierre-ChristopheDus You have to remove the tittle from Forms. Use this in your page:

    Title = ""

    I think the use of the renderer is now obsolete

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    Ok, thanks for your answer.
    Do you know if it's possible to display the icon on a single page only?
    I tried to play with a CustomRenderer, but it is called only once...

  • codercamposcodercampos SVMember ✭✭

    I think the only way to this is changing the Toolbar layout when you are on a specific page. I don't even if this is posisble, but as I see you can play with both custom renderer (depending on the page is being shown, change the toolbar xml) or DependencyService (this could messy and tricky to handle)

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    Yes I would like to change the Toolbar through a renderer, with the OnViewAdded() method.
    But I have a doubt: it seems that the method is called after the display of the new page.
    Furthermore, if I can get the current Xamarin.Forms page with the QuickView, it doesn't seem to be possible in the code.
    I describe the expected solution and the encountered problem here.

Sign In or Register to comment.