Android SVG矢量图主题切换功能

#Android SVG 矢量图做主题换肤

##Step 1. Add the JitPack repository to your build file
```java
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
```
##Step 2. Add the dependency   
```java
 dependencies {
            implementation 'com.github.wy749814530:SvgImageView:1.1.1'
    }
```

##Step 3    
```java
    <com.svg.SvgImageView
        android:id="@+id/svgImageView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_margin="18dp"
        appL:image="@drawable/ic_car"
     />
     
     SvgImageView svgImageView = findViewById(R.id.svgImageView);


    /**
     * 修改图层颜色
     *
     * @param view
     */
    svgImageView.setGroupColorByIndex(0, getResources().getColor(R.color.colorAccent));


    /**
     * 修改Path颜色
     *
     * @param view
     */
    svgImageView.setPathColorByIndex(0, getResources().getColor(R.color.colorAccent));

    /**
     * 修改所以Path颜色
     *
     * @param view
     */
    svgImageView.setPathsColor(getResources().getColor(R.color.colorAccent));

    /**
     * 还原SVG图原始色
     *
     * @param view
     */
    public void onRestore(View view) {
        svgImageView.resetColors();
    }

```
 

Github地址:https://github.com/wy749814530/SvgImageView

原创文章 4 获赞 1 访问量 68

猜你喜欢

转载自blog.csdn.net/weixin_42169702/article/details/106055031