【发布时间】:2021-07-03 15:11:48
【问题描述】:
【问题讨论】:
标签: xamarin.forms xamarin.android
【问题讨论】:
标签: xamarin.forms xamarin.android
您可以尝试使用自定义渲染器来设置图标。并将ItemIconTintList 设置为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
}
}
}
}
更新:
如果你想改变shell的汉堡图标,你可以使用自定义渲染器将图标重置为CreateToolbarAppearanceTracker。
更多细节,你可以参考我之前做的线程。 How to hide back button in navigation bar using Xamarin.Forms - AppShell?
如果你想改变导航栏的后退按钮颜色,你可以设置样式。请检查下面的链接。 Change back button color in Xamarin.Android
【讨论】: