在Xamarin中跨项目共享图像 [英] Sharing images across projects in Xamarin

查看:74
本文介绍了在Xamarin中跨项目共享图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Xamarin的多个设备应用程序中使用相同的图像.

I'd like to use the same images in multiple device apps in Xamarin.

我有一个PCL核心库,并已开始使用MVVMCross. 什么是最好的方法来做到这一点?我可以将它们作为资源嵌入到Core库中,并在我的Andriod/iOs项目中访问它,还是最好使用add as链接?

I have a PCL core library and have started using MVVMCross. What's the best approach to accomplish this? Can I embed them as a resource in the Core library and access it in my Andriod/iOs project, or is it better to use add as link?

推荐答案

理论上,您可以将它们作为二进制资源嵌入PCL项目中,然后可以通过GetResourceStreambyte[]的身份访问它们,然后从那里获取它们在您的UI项目中解码.这将需要进行一些设置工作,并且无法在xib编辑器,android XML等中使用图像

You can in theory embed these as binary resources in the PCL project and can then access them as byte[] via GetResourceStream and from there can then get them decoded in your UI projects. This would require some work to setup and would make it impossible to use the images in the xib editor, in the android XML, etc

更轻松地,您还可以使用添加为链接"共享这些图像文件,然后允许每个平台优化和打包文件-每个平台都擅长-例如具有不同dpi可绘制文件夹的Android和具有以下功能的IOS其2倍图像包装.这种技术也适用于xib和XML设计器.

More easily, you can also share these image files using 'Add as link' and then allow each individual platform to optimize and package the files - each platform is good at this - eg Android with its different dpi drawable folders and IOS with its 2x image packaging. This technique also works well with the xib and XML designers.

但是,实际上,我通常发现我并没有在项目之间共享这些图像文件-在大多数商业项目中,PhotoShop的家伙坚持要求给我图标,分隔线和每个平台特有的其他chrome图像.

However, in practice I generally find I don't share these image files between projects - instead on most commercial projects, the PhotoShop guys insist on giving me icons, dividers, and other chrome images which are unique to each platform.

这篇关于在Xamarin中跨项目共享图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆