I am having issues of SVG Scaling on Android Phones.
Couple of parts of my website are based on having both width and height dimensions for SVGs embeded via <img>
tag.
All the browsers except Android 4.1.2 Native Browser(NOT CHROME),scale SVGs Properly and perfectly without distorting Aspect Ratio.
Here is screenshot of how it appears on Firefox(and all the browsers)
Here is screenshot of how it appears on the Android 4.1.2 Native Browser.
Testing URL http://prashantsani.com/demos/svgIssue/
I tried all below solutions but none of them worked.
Setting width, height and view-box does not work. Also, preserveAspectRatio does not work either.
<svg width="443.5" height="100" viewBox="0 0 443.5 100" preserveAspectRatio="xMidYMid meet">
Wrapping up inside another SVG did not do the trick (Also, i don't want to center the image, rather need a way scale the image propotionately). Programmatically centering svg path
I Tried this : SVG Resize Image out of aspect ratio but it does not work either. The width and height is already set in integers and not % or px.
Please read following before Answering:
- Since the layout demands both width and height at some places, I have to keep both at some places.
- This issue ONLY happens in NATIVE BROWSER APP on Android 4.1.2{"Browser" App} . It works brilliantly, as expected in Chrome and all other browsers on Android 4.1.2.
- A fiddle or codepen will be helpful if you find a solution.
- Not planning to use any image format other than SVG.
- Width and height and mentioned in % via css....and SVG has to scale accordingly.
Thanks.