How can I automatically scale an SVG element within a React Native View?

后端 未结 4 991
隐瞒了意图╮
隐瞒了意图╮ 2021-02-07 01:10

I am trying to put a react-native-svg element inside of a View such that it\'s rendered with a certain, fixed aspect ratio, but then scaled to be as la

4条回答
  •  礼貌的吻别
    2021-02-07 01:43

    You have to play with the width and height together with the viewBox. Usually the viewBox you have to place the original dimensions of your desired shape. And by defining the width/height based on your needs your shape will be down/up scaled properly.

    Please have a look to this tutorial where this concepts have been explained pretty clear.

    https://www.sarasoueidan.com/blog/svg-coordinate-systems/

提交回复
热议问题