How to add your textures to xamarin? Where should they be thrown and where to prescribe? I tried to just throw in the path C: \ Users \ User \ Documents \ Visual Studio 2015 \ Projects \ App \ App \ obj \ Debug \ res \ drawable, but from there they are deleted when debugging.

    1 answer 1

    You can add media files to the Resources / drawable android project folder, put BuildAction: AndroidResource, then access them as follows:

    public static class ResourceLoader { public static Stream StreamResource(string baseName) { var assembly = typeof(ResourceLoader).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream(baseName); return stream; } } ResourceLoader.StreamResource("AssemblyName.Folder1.Folder2.file.png")); 

    another option: having a file in the "drawable" folder named "background.png" (Android resource)

     public static void LoadBitmapDataFromResource(int resourceId) { Bitmap b = BitmapFactory.DecodeResource( Forms.Context.Resources, resourceId); LoadBitmapDataToTexture(b); b.Recycle(); } public static int DrawableResourceIdFromName(string name) { return ResourceIdFromNameAndResourceType(name, "drawable"); } public static int ResourceIdFromNameAndResourceType(string name, string resourceType) { var context = Forms.Context; return context.Resources.GetIdentifier(name, resourceType, context.PackageName); } LoadBitmapDataFromResource(DrawableResourceIdFromName("background1"));