Is there a way to access a Vector programmable?

Asked

Viewed 24 times

-2

I have a vector of a star and wanted to access a path of it from within my Java class to change the color.

<vector android:height="24dp" android:viewportHeight="197.24483"
    android:viewportWidth="207.1335" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#00000000"
        android:pathData="m103.377,106.274 l3.874,-18.615 6.993,3.402z"
        android:strokeAlpha="1" android:strokeColor="#000000"
        android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
    <path android:fillColor="#00000000"
        android:pathData="m103.377,106.274 l3.874,-18.615h-7.371z"
        android:strokeAlpha="1" android:strokeColor="#000000"
        android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
    <path android:fillColor="#00000000"
        android:pathData="m103.377,106.274 l10.867,-15.214 5.008,6.237z"
        android:strokeAlpha="1" android:strokeColor="#000000"
        android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
    <path android:fillColor="#00000000"
        android:pathData="m103.377,106.274 l-3.496,-18.615 -7.182,3.591z"
        android:strokeAlpha="1" android:strokeColor="#000000"
        android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
    <path android:fillColor="#00000000"
        android:pathData="m103.377,106.274 l17.859,-1.512 -1.984,-7.465z"
        android:strokeAlpha="1" android:strokeColor="#000000"
        android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>

inserir a descrição da imagem aqui

1 answer

1


You can use an external library called Vectorchildfinder.

VectorChildFinder vector = new VectorChildFinder(this, R.drawable.meu_vetor, imageView);

VectorDrawableCompat.VFullPath path1 = vector.findPathByName("path1");
path1.setFillColor(Color.RED);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.