Xamarin.Forms.Plugins icon indicating copy to clipboard operation
Xamarin.Forms.Plugins copied to clipboard

SVGs don't handle scaling properly

Open JoshuaNovak919 opened this issue 8 years ago • 3 comments

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

JoshuaNovak919 avatar Mar 01 '16 21:03 JoshuaNovak919

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.

mannyvw avatar Nov 17 '16 10:11 mannyvw

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.

rodja avatar Dec 28 '16 16:12 rodja

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,
        };

rodja avatar Dec 28 '16 16:12 rodja