0

Hello i am trying to set icon of bottom nav bar

Icon

But everytime it changes color of whole icon and then it look like this Icon

Is it possible to not give icon color so it wont change whole icon?

Bujdy
  • 1

1 Answers1

0

You could try to use the custom renderer to the set the icon. And set the ItemIconTintList to null.

[assembly: ExportRenderer(typeof(AppShell), typeof(ShellCustomRenderer))]
namespace App_Shell.Droid
{
class ShellCustomRenderer : ShellRenderer
{
    public ShellCustomRenderer(Context context) : base(context)
    {
    }

    protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
    {
        return new CustomBottomNavAppearance();
    }
}
public class CustomBottomNavAppearance : IShellBottomNavViewAppearanceTracker
{
    public void Dispose()
    {

    }

    public void ResetAppearance(BottomNavigationView bottomView)
    {

    }

    public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
    {

        bottomView.ItemIconTintList = null;
        IMenu myMenu = bottomView.Menu;

        IMenuItem myItemOne = myMenu.GetItem(0);

        if (myItemOne.IsChecked)
        {
            myItemOne.SetIcon(Resource.Drawable.cactus_24px); // selected icon
        }
        else
        {
            myItemOne.SetIcon(Resource.Drawable.icon_about); //default icon
        }

    }
}
}

Update:

If you want to change the burger icon of shell, you could use Custom renderer to reset the icon vis CreateToolbarAppearanceTracker.

For more details, you could refer to the thread i done before. How to hide back button in navigation bar using Xamarin.Forms - AppShell?

If you want to change the back button color of navigation bar, you could set in style. Please check the link below. Change back button color in Xamarin.Android

Wendy Zang - MSFT
  • 10,509
  • 1
  • 7
  • 17
  • I changed white color in icons to transparent color and its OK now :D But yours also works.. Now i just need to find out how to change color of Back Button. I changed icon with BackButtonBehaviour and icon is for some reason white (even though i used black icon) – Bujdy Jul 06 '21 at 12:00
  • I have updated my reply. Please check it. – Wendy Zang - MSFT Jul 07 '21 at 08:19
  • I was trying to change back buton color but it doesnt work. It didnt change color of back button but it changed few colors in my app (like in yours that top bar to gray color) so probably its outdated. – Bujdy Jul 08 '21 at 10:32
  • I tried to do it with toolbar. The good thing is my icon is black and also it redirects me back to prev page. But bad thing that on main page it opens toolbar menu. Is there way to like remove that toolbar menu, only on my main page? – Bujdy Jul 08 '21 at 10:54
  • The link i provided is to use the theme to change the back button color. It would cover the origianl theme's color. You could create you own. And When you change the toolbar. It would change all the page's toolbar. You could remove on specific page. – Wendy Zang - MSFT Jul 12 '21 at 09:00