Xamarin cross plataform solution with 9 patch
Is there a way to work with stretchable images like 9-patch for android or resizableImageWithCapInsets: edgeInsets for IOS on all platforms?
In traditional Xamarin development, you need to deal with the native platform image capabilities. The frameworks don't share any image format, and you wouldn't want to handle image agnostics anyway, since the native classes are optimized for memory and performance. You will lose all the benefits of this optimization.
In Xamarin.Forms you will need to look for a third party library like NGraphics, or NControl , maybe ...
See this excellent article on Working with Images in Xamarin.Forms.
There is a paid library http://forms9patch.com , I used it myself and it is pretty solid
You can convert any image to 9patch cross-platform:
var image2 = new Forms9Patch.Image () {
Source = ImageSource.FromResource("MyDemoApp.Resources.Images.redribbon.png"),
CapInsets = new Thickness(23, 0, 110, 0),
}
EDIT: Please note that Forms9Patch license is not required to use Forms9Patch.ImageSource. So you can use Forms9Patch.ImageSource using this library for free