Android SVG 矢量圖做主題換膚

Android SVG 矢量圖做主題換膚

Step 1. Add the JitPack repository to your build file

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

 dependencies {
            implementation 'com.github.wy749814530:SvgImageView:1.1.1'
    }

Step 3

    <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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章