我应该在哪里为Xamarin.Forms中的TabbedPage添加图标

Bob*_*421 4 android ios xamarin xamarin.forms

我正在开发一个多平台(Android/iOS)Xamarin.Forms应用程序.

我已经放了一个TabbedPage.我想为每个页面定义一个Icon.我试过在XAML文件中设置Icon Propery:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            x:Class="XXXX.YYYY">
<TabbedPage.Children>
    <ContentPage Title="Recherche" Icon="search.png">
Run Code Online (Sandbox Code Playgroud)

我在Xamarin预览中有一个错误,当我在iOS模拟器中尝试时,它是一个空白的应用程序.

我的问题是:我应该把search.png文件放在哪里?

在共享项目中?在特定的子文件夹中?

在每个iOS/Android子项目中?

谢谢

Tim*_*äki 6

图像资产需要位于每个特定于平台的项目上,以便为每个操作系统正确调整大小,命名和格式化.

阅读本文以更好地了解图像:使用图像

iOS - 使用Build Action:BundleResource将图像放在Resources文件夹中.还应提供图像的Retina版本 - 分辨率的两倍和三倍,文件扩展名前的文件名后缀为@ 2x或@ 3x(例如myimage@2x.png).

Android - 使用Build Action:AndroidResource将图像放在Resources/drawable目录中.还可以提供图像的高DPI和低DPI版本(在适当命名的Resources子目录中,例如drawable-ldpi,drawable-hdpi和drawable-xhdpi).

Windows Phone - 使用Build Action:Content将图像放在应用程序的根目录中.

Windows/UWP - 使用Build Action:Content将图像放在应用程序的根目录中.

正确放置图像后,您可以正确使用它们Icon="search.png".