Xamarin 图像未显示在 TabbedPage 中
Xamarin image not showing in TabbedPage
我有一张姓名为 logout.png 的图片,我试图将其显示在标签页中。但它给我显示了一个很大的灰色圆圈。当我把它放在另一个页面时,它显示没有问题
<NavigationPage Title="{Static properties:Resources.LabelLogout}" Icon="logout.png">
<x:Arguments>
<views:LogoutPage/>
</x:Arguments>
</NavigationPage>
您应该使用 IconImageSource="logout.png"
为 Tabbar 设置图标,而不是 Icon="logout.png"
。看看下面的示例代码:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageWithNavigationPage;assembly=TabbedPageWithNavigationPage"
x:Class="TabbedPageWithNavigationPage.MainPage">
<local:TodayPage />
<NavigationPage Title="Schedule" IconImageSource="schedule.png">
<x:Arguments>
<local:SchedulePage />
</x:Arguments>
</NavigationPage>
</TabbedPage>
这里有一个official sample project供参考。
我有一张姓名为 logout.png 的图片,我试图将其显示在标签页中。但它给我显示了一个很大的灰色圆圈。当我把它放在另一个页面时,它显示没有问题
<NavigationPage Title="{Static properties:Resources.LabelLogout}" Icon="logout.png">
<x:Arguments>
<views:LogoutPage/>
</x:Arguments>
</NavigationPage>
您应该使用 IconImageSource="logout.png"
为 Tabbar 设置图标,而不是 Icon="logout.png"
。看看下面的示例代码:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageWithNavigationPage;assembly=TabbedPageWithNavigationPage"
x:Class="TabbedPageWithNavigationPage.MainPage">
<local:TodayPage />
<NavigationPage Title="Schedule" IconImageSource="schedule.png">
<x:Arguments>
<local:SchedulePage />
</x:Arguments>
</NavigationPage>
</TabbedPage>
这里有一个official sample project供参考。