【问题标题】:Android Vector Asset Studio: Import SVG and use ID as NameAndroid Vector Asset Studio:导入 SVG 并使用 ID 作为名称
【发布时间】:2020-01-10 22:34:45
【问题描述】:

我正在使用 Vector Asset Studio 将 SVG 文件作为 Vector Drawable 导入。每次我这样做时,它都会在生成的 XML 文件中删除我的 SVG 的“id”属性。我认为它们将被转换为 xml 文件中的“名称”属性,因为它们都是标识符。

我使用 Inkscape 创建了我的 svg,所以我可以直接绘制它。这是我的 svg 文件中的一个 sn-p:

<rect
         inkscape:label="#rect1067"
         y="50.32835"
         x="154.16335"
         height="25.92329"
         width="23.673288"
         id="lobby-link"
         style="fill:none;fill-opacity:1;stroke:#000000;
         stroke-width:0.32671064;stroke-miterlimit:4;
         stroke-dasharray:none;stroke-opacity:1" />

这是生成的 xml 文件中的一个 sn-p:

<path
        android:fillAlpha="1"
        android:fillColor="#00000000"
        android:pathData="M154.163,50.328h23.673v25.923h-23.673z"
        android:strokeWidth="0.32671064"
        android:strokeAlpha="1"
        android:strokeColor="#000000" />

有没有办法让我实现生成的 sn-p 将包含以下内容:android:name="lobby-link"?

【问题讨论】:

    标签: android android-studio android-vectordrawable


    【解决方案1】:

    有一个名为svg2android 的外部工具。虽然我不推荐使用它,因为它已被弃用,但它支持将您的 ID 转换为 android name 属性。只需拖动要转换的 SVG 文件并单击“从 SVG 导入 ID 作为名称”复选框。

    【讨论】:

      猜你喜欢
      • 2016-06-21
      • 2016-08-22
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      • 2017-05-02
      • 2023-01-03
      • 2015-12-03
      相关资源
      最近更新 更多