项目作者: bardss

项目描述 :
PaintableVectorView enables to change color of paths/groups in Vector Drawable (SVG)
高级语言: Kotlin
项目地址: git://github.com/bardss/PaintableVectorView.git
创建时间: 2019-12-30T19:11:10Z
项目社区:https://github.com/bardss/PaintableVectorView

开源协议:

下载


PaintableVectorView

PaintableVectorView enables to change color of paths/groups in Vector Drawable (SVG)

Demo

Alt Text

Car icon made by Prosymbols from www.flaticon.com

Dependency

Add the following lines in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Add the dependency

  1. dependencies {
  2. implementation 'com.github.bardss:PaintableVectorView:1.0.4'
  3. }

Usage

Create PaintableVectorView and add to the layout:

  1. val paintableView = PaintableVectorView(
  2. context = this,
  3. drawableId = R.drawable.ic_car,
  4. paintType = PaintType.PAINT_PATH,
  5. paintColor = resources.getColor(R.color.blue)
  6. )
  7. layout.addView(paintableView)

Or add in xml and set attributes:

  1. <com.jakubaniola.paintablevectorview.PaintableVectorView
  2. android:id="@+id/paintableView"
  3. android:layout_width="200dp"
  4. android:layout_height="200dp"
  5. android:layout_margin="18dp"
  6. app:drawable="@drawable/ic_car"
  7. app:paintColor="@color/blue"
  8. app:paintType="GROUP" ></com.jakubaniola.paintablevectorview.PaintableVectorView>

Set other paint type:

  1. paintableView.paintType = PaintType.PAINT_GROUP
  1. app:paintType="GROUP"
  1. app:paintType="PATH"

Set other paint color:

  1. paintableView.paintColor = resources.getColor(R.color.blue)
  1. app:paintColor="@color/blue"

Reset layers color in PaintableVectorView:

  1. paintableView.resetColors()

License

  1. Copyright 2019 Jakub Aniola
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.