0

I'm a themer/icon pack designer/wanna be developer and still very green when it comes to the development side of things. I'm working on a proof of concept app (pictured below). The glyph is drawn with vector drawables, what I'm hoping to be able to do is change the glyph colors based on user input, sharedpreferences, and colors.xml. Is this possible?

screen shot

Here is my vector drawable:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="512dp"
    android:width="512dp"
    android:viewportHeight="512"
    android:viewportWidth="512" >

    <path
        android:fillColor="@color/color1"
        android:pathData="M202.10841,96.680962 l 125.2736,0 c 56.96724,0 102.82896,45.861718
102.82896,102.828958 l 0,112.03633 c 0,56.96724 -45.86172,102.82896
-102.82896,102.82896 l -125.2736,0 c -56.96725,0 -102.828961,-45.86172
-102.828961,-102.82896 l 0,-112.03633 c 0,-56.96724 45.861711,-102.828958
102.828961,-102.828958 z" />

    <group
        android:translateY="-540.36218">
        <path
            android:fillColor="@color/color2"
            android:pathData="M 325.04765,949.21307 c -12.01898,-14.90788 -21.85269,-27.46213
-21.85269,-27.89835 0,-0.77921 46.37104,-55.98752 47.02552,-55.98752 0.18412,0
19.7568,11.76794 43.49485,26.15098 29.51558,17.88368 43.50455,26.907
44.24969,28.54239 0.89613,1.96679 0.74694,2.71968 -0.84023,4.24015
-1.06141,1.0168 -21.50483,12.97315 -45.42983,26.56968 -23.925,13.59652
-43.79129,24.89351 -44.14731,25.10442 -0.35602,0.21091 -10.48102,-11.81387
-22.5,-26.72175 z" />
    </group>

</vector

>

nmiltner
  • 207
  • 1
  • 2
  • 12
  • @Frank N. Stein: The similar question doesn't really answer my question. In my case, is like to have user input change the full color of the drawable. Not handle a color change with an animation. – nmiltner Oct 19 '15 at 15:58
  • So, you didn't read the answer. It's explicitly said `You don't have a direct access to the inner elements in VectorDrawable.` – Phantômaxx Oct 19 '15 at 16:05
  • Perhaps a better way to phrase it then, as I get i can't change the hard coded @color value inside the vector drawable. Is it possible to modify/redirect the color value in colors.xml using shared preferences? Or am in interpreting the usage of shared preferences incorrectly. – nmiltner Oct 19 '15 at 17:15
  • `colors.xml` is a resource file. As such, it can't be written programmatically. SharedPreferences are used to store user settings as key/value pairs. – Phantômaxx Oct 19 '15 at 17:18

0 Answers0