Search code examples
androidandroid-studiosvgvector-graphics

Android Studio replace color from vector graphic


I downloaded the google logo in .svg format as shown here: here

However, when I import it in Android Studio, the logo replaces the blue color with green and shows it without the blue color (green instead) on the device.

enter image description here


Solution

  • I tried importing the same icon into an empty project, I saw the same behavior as you. If you click the little "Override" button on/off it seemed to fix the problem, if only temporarily. The below XML shows the correct coloring for me, try pasting it directly into your current file:

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportHeight="48.0"
        android:viewportWidth="48.0">
        <group>
            <clip-path android:pathData="M44.5,20H24v8.5h11.8C34.7,33.9 30.1,37 24,37c-7.2,0 -13,-5.8 -13,-13s5.8,-13 13,-13c3.1,0 5.9,1.1 8.1,2.9l6.4,-6.4C34.6,4.1 29.6,2 24,2 11.8,2 2,11.8 2,24s9.8,22 22,22c11,0 21,-8 21,-22 0,-1.3 -0.2,-2.7 -0.5,-4z M 0,0" />
            <path
                android:fillColor="#FBBC05"
                android:pathData="M0 37V11l17 13z" />
        </group>
        <group>
            <clip-path android:pathData="M44.5,20H24v8.5h11.8C34.7,33.9 30.1,37 24,37c-7.2,0 -13,-5.8 -13,-13s5.8,-13 13,-13c3.1,0 5.9,1.1 8.1,2.9l6.4,-6.4C34.6,4.1 29.6,2 24,2 11.8,2 2,11.8 2,24s9.8,22 22,22c11,0 21,-8 21,-22 0,-1.3 -0.2,-2.7 -0.5,-4z M 0,0" />
            <path
                android:fillColor="#EA4335"
                android:pathData="M0 11l17 13 7,-6.1L48 14V0H0z" />
        </group>
        <group>
            <clip-path android:pathData="M44.5,20H24v8.5h11.8C34.7,33.9 30.1,37 24,37c-7.2,0 -13,-5.8 -13,-13s5.8,-13 13,-13c3.1,0 5.9,1.1 8.1,2.9l6.4,-6.4C34.6,4.1 29.6,2 24,2 11.8,2 2,11.8 2,24s9.8,22 22,22c11,0 21,-8 21,-22 0,-1.3 -0.2,-2.7 -0.5,-4z M 0,0" />
            <path
                android:fillColor="#34A853"
                android:pathData="M0 37l30,-23 7.9 1L48 0v48H0z" />
        </group>
        <group>
            <clip-path android:pathData="M44.5,20H24v8.5h11.8C34.7,33.9 30.1,37 24,37c-7.2,0 -13,-5.8 -13,-13s5.8,-13 13,-13c3.1,0 5.9,1.1 8.1,2.9l6.4,-6.4C34.6,4.1 29.6,2 24,2 11.8,2 2,11.8 2,24s9.8,22 22,22c11,0 21,-8 21,-22 0,-1.3 -0.2,-2.7 -0.5,-4z M 0,0" />
            <path
                android:fillColor="#4285F4"
                android:pathData="M48 48L17 24l-4,-3 35,-10z" />
        </group>
    </vector>