Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should i put icons for TabbedPage in Xamarin.Forms

I am working on a multiplatform (Android/iOS) Xamarin.Forms app.

I have put a TabbedPage. I want to define an Icon for each page. I have tried do set Icon Propery in XAML file:

<?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">

I have an error in Xamarin preview and a blank app when i try it in iOS simulator.

My question is: Where should i put search.png file?

In shared project? In a particular subfolder?

In each iOS/Android subproject?

like image 273
Bob5421 Avatar asked Feb 16 '17 11:02

Bob5421


1 Answers

The image assets need to be on each platform specific project so that they are correctly sized, named and formatted for each OS.

Read this article to get a better understanding about images: Working with Images

iOS - Place images in the Resources folder with Build Action: BundleResource. Retina versions of the image should also be supplied - two and three times the resolution with a @2x or @3x suffixes on the filename before the file extension (eg. [email protected]).

Android - Place images in the Resources/drawable directory with Build Action: AndroidResource. High- and low-DPI versions of an image can also be supplied (in appropriately named Resources subdirectories such as drawable-ldpi, drawable-hdpi, and drawable-xhdpi).

Windows Phone - Place images in the application's root directory with Build Action: Content.

Windows/UWP - Place images in the application's root directory with Build Action: Content.

After you have correctly placed the images, you can properly use them with for example Icon="search.png".

like image 121
Timo Salomäki Avatar answered Sep 25 '22 00:09

Timo Salomäki