有没有办法在SVG中应用9-patch / scale-9原则?

有没有办法在SVG中应用9-patch / scale-9原则?

问题描述:

我想知道是否有办法制作一个svg图形,可以根据与 9-patch (或闪存中的9级补丁)。

I'm wondering if there is a way to make an svg graphic that would scale accordingly to the same principle as 9-patch on Android (or like scale 9 in flash).

基本上,svg内部的部分内容应该扩展相应于视口的正常扩展规则,但某些元素将保持未缩放和锚定,如svg文件中所定义。

Basically, part of the content inside the svg should scale accordingly to the normal expansion rules of the viewport but certain elements would remain unscaled and anchored as defined in the svg file.

(这个想法是为了制作一些复杂的背景一些按钮使用SVG,但允许它们按钮的内部内容进行相应缩放)

(The idea would be to make some complicated background for some buttons using SVG but allowing them to scale accordingly with the inner content of the button)

我不认为使用普通的svg声明是可能的,但也许有点嵌入式脚本编写,虽然我找不到任何示例或库这样做..

I don't think it's possible with plain svg declarations, but maybe with a bit of embedded scripting, though I couldn't find any example or library doing this..

**编辑:**我知道今年的SO问题但我很高兴选择某人可能有一个替代的,更可重复使用的选项/库

** ** I'm aware of this year old SO question but I'm hoping someone may have an alternative, more reusable option / library

我在我的博客上写过它,它可能在一个当你愿意牺牲IE以及在IE中运行的几乎方式以及你可以忍受一个不那么完美的解决方案的时候,完美的方式: http://w3.eleqtriq.com/2014/03/the-holy-grail-of-image-scaling/

I wrote about it on my blog, it's possible in a "perfect" way when you are willing to sacrifice IE and an "almost" way that works in IE as well as long as you can live with a not so perfect solution: http://w3.eleqtriq.com/2014/03/the-holy-grail-of-image-scaling/