Xamarin.Forms.Plugins
Xamarin.Forms.Plugins copied to clipboard
SVGs don't handle scaling properly
I've been trying to add an SVG as a border in one of my apps. In trying to do so I realized that this plugin doesn't seem to handle scaling properly. On iOS it preserves the aspect ratio. On Android it scales the SVG, but leaves some space. I've put a link to a sample project below that just shows a simple rectangle SVG and how it is very different on both iOS and Android. It also shows that when I use AbsoluteLayout
, there is some space on Android. I think it makes sense for this plugin to respect the preserveAspectRatio
attribute for scaling and handle it the same on both platforms.
https://drive.google.com/file/d/0B68aZqcn2sxXS2Z6bWRZOFFfTk0/view?usp=sharing
Have crated a PR for this https://github.com/paulpatarinski/Xamarin.Forms.Plugins/pull/116 hopefully Paul will merge soon in mean time am using local nuget package.
Thanks @mannyvw for creating the PR. @paulpatarinski, could you release a new NuGet Package with this fix soon? Currently all SVG images are not preserving there aspect ratio on Android.
Oh, I have found a solution for my aspect ratio problem on Android. Just set HorizontalOptions and VerticalOptions to Center:
new SvgImage {
SvgAssembly = typeof(App).GetTypeInfo().Assembly,
SvgPath = "logo.svg",
WidthRequest = 178,
HeightRequest = 22,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
};