Guilherme Torres Castro
Guilherme Torres Castro

Reputation: 15350

Xamarin cross plataform 9-patch like solution

Is there a way to work with stretchable images like 9-patch for android or resizableImageWithCapInsets:edgeInsets for IOS on all platforms?

Upvotes: 4

Views: 1561

Answers (2)

Artem Zelinskiy
Artem Zelinskiy

Reputation: 2210

There is a paid library http://forms9patch.com i have used it myself and it is pretty solid

You can turn any image to 9patch in crossplaform manner:

var image2 = new Forms9Patch.Image () {
    Source = ImageSource.FromResource("MyDemoApp.Resources.Images.redribbon.png"),
    CapInsets = new Thickness(23, 0, 110, 0),
}

enter image description here

EDIT: Note that a Forms9Patch license is not required to use Forms9Patch.ImageSource. So you can use Forms9Patch.ImageSource using this library for free

Upvotes: 1

der_michael
der_michael

Reputation: 3362

In traditional Xamarin development you need to deal with the platform native image capabilities. The platforms don't share any image format and you wouldn't want to handle images platform agnostic anyways as the native classes are optimized for memory and performance. You would lose every benefit of those optimization.

In Xamarin.Forms you would need to look for a 3rd party library like NGraphics or NControl maybe...

See this excellent article about Working with Images in Xamarin.Forms.

Upvotes: 1

Related Questions