Android SVG Drawable 插件使用教程

Android SVG Drawable 插件使用教程

androidsvgdrawable-pluginGradle plugin that generates qualified, density specific PNG drawables from SVG files at build time for your Android projects.项目地址:https://gitcode.com/gh_mirrors/an/androidsvgdrawable-plugin

1. 项目的目录结构及介绍

Android SVG Drawable 插件的 GitHub 仓库目录结构如下:

androidsvgdrawable-plugin/
├── plugin/
│   ├── src/
│   └── build.gradle
├── sample/
│   ├── src/
│   └── build.gradle
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
  • plugin/:包含插件的主要代码和资源。
  • sample/:包含插件的示例项目,展示了如何使用插件。
  • .gitignore:Git 忽略文件配置。
  • .travis.yml:Travis CI 配置文件。
  • CHANGELOG.md:项目更新日志。
  • LICENSE:项目许可证。
  • README.md:项目说明文档。

2. 项目的启动文件介绍

项目的启动文件主要是 plugin/build.gradlesample/build.gradle

plugin/build.gradle

该文件定义了插件的构建配置,包括依赖项、任务和插件的版本等信息。

sample/build.gradle

该文件定义了示例项目的构建配置,展示了如何应用插件并配置任务。

3. 项目的配置文件介绍

build.gradle

build.gradle 文件中,你需要应用插件并配置任务。以下是一个典型的配置示例:

apply plugin: 'com.android.application'
apply plugin: 'androidsvgdrawable'

// 创建一个任务将 SVG 转换为 PNG
task svgToPng(type: fr.avianey.androidsvgdrawable.gradle.SvgDrawableTask) {
    // 配置,参见示例项目
}

pom.xml

如果你使用 Maven,可以在 pom.xml 中添加插件配置:

<plugin>
    <groupId>fr.avianey.androidsvgdrawable</groupId>
    <artifactId>maven-plugin</artifactId>
    <executions>
        <execution>
            <id>gendrawable-png</id>
            <configuration>
                <!-- 配置,参见示例项目 -->
            </configuration>
            <phase>initialize</phase>
            <goals>
                <goal>gen</goal>
            </goals>
        </execution>
    </executions>
</plugin>

通过以上配置,你可以在构建过程中自动生成密度特定的 PNG 资源。

androidsvgdrawable-pluginGradle plugin that generates qualified, density specific PNG drawables from SVG files at build time for your Android projects.项目地址:https://gitcode.com/gh_mirrors/an/androidsvgdrawable-plugin

  • 24
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乔吟皎Gilbert

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值