I imported a svg into drawables folder as a vector asset. In drawable preview
its showing the render properly
But when i render them through code it showing as a fully black image.(ignore green bar)
XML
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="493.46dp"
android:height="480.85dp"
android:viewportWidth="493.46"
android:viewportHeight="480.85">
<path
android:pathData="M314.74,107.79L288.48,107.79L288.48,331.64a26.74,26.74 0,0 1,-26.74 26.74L61,358.38v0.26a26.74,26.74 0,0 0,26.74 26.74h226.99a26.74,26.74 0,0 0,26.74 -26.74L341.48,134.53A26.74,26.74 0,0 0,314.74 107.79Z"
android:fillColor="#f2f2f2"/>
<path
android:pathData="M240.72,77.34a8.25,8.25 0,0 0,12.47 1.53l37.47,16.9 7.22,-9.21 -44.64,-19.75a8.23,8.23 0,0 0,-12.51 10.54Z"
android:fillColor="#a0616a"/>
<path
android:pathData="M401.51,87.88l3.72,21.06a7.15,7.15 0,0 1,-6.49 8.38l-63.14,4.97L261.38,89.06l8.86,-16.83L334.67,92.64Z"
android:fillColor="#6c63ff"/>
<path
android:pathData="M26.74,72.79L253.74,72.79A26.74,26.74 0,0 1,280.48 99.53L280.48,323.64A26.74,26.74 0,0 1,253.74 350.38L26.74,350.38A26.74,26.74 0,0 1,0 323.64L0,99.53A26.74,26.74 0,0 1,26.74 72.79z"
android:fillColor="#f2f2f2"/>
<path
android:pathData="M26.74,78.29a21.24,21.24 0,0 0,-21.24 21.24L5.5,323.64a21.24,21.24 0,0 0,21.24 21.24L171.62,344.88A103.36,103.36 0,0 0,274.98 241.52L274.98,99.53a21.24,21.24 0,0 0,-21.24 -21.24Z"
android:fillColor="#fff"/>
<path
android:pathData="M203.7,146.3L76.29,146.3a4.41,4.41 0,1 1,0 -8.82L203.7,137.48a4.41,4.41 0,0 1,0 8.82Z"
android:fillColor="#f2f2f2"/>
<path
android:pathData="M203.7,240.3L76.29,240.3a4.41,4.41 0,1 1,0 -8.82L203.7,231.48a4.41,4.41 0,0 1,0 8.82Z"
android:fillColor="#f2f2f2"/>
<path
android:pathData="M255.43,193.33L24.55,193.33a4.41,4.41 0,1 1,0 -8.82L255.43,184.51a4.41,4.41 0,0 1,0 8.82Z"
android:fillColor="#f2f2f2"/>
<path
android:pathData="M393.53,180.69l-23,49l88.48,-8.96l-18.47,-47.04l-47.01,7z"
android:fillColor="#a0616a"/>
<path
android:pathData="M414.1,462.32l-8.39,-0.07l-3.71,-33.11l12.38,0.11l-0.28,33.08z"
android:fillColor="#a0616a"/>
<path
android:pathData="M387.23,475.66a3.76,3.76 0,0 0,3.72 3.78l16.68,0.14 2.92,-5.92 1.07,5.95 6.29,0.06 -1.59,-21.22 -2.19,-0.15 -8.93,-0.62 -2.88,-0.19 -0.05,6 -13.4,9.09A3.75,3.75 0,0 0,387.23 475.66Z"
android:fillColor="#2f2e41"/>
<path
android:pathData="M321.27,462.36l-8,-2.53l6.18,-32.74l11.8,3.74l-9.99,31.54z"
android:fillColor="#a0616a"/>
<path
android:pathData="M291.66,467.21a3.76,3.76 0,0 0,2.44 4.71l15.9,5.03 4.53,-4.8 -0.72,6 6,1.9L324.53,459.31l-2.05,-0.78 -8.36,-3.21 -2.7,-1.03 -1.81,5.72 -15.48,4.75A3.75,3.75 0,0 0,291.66 467.21Z"
android:fillColor="#2f2e41"/>
<path
android:pathData="M454.98,206.95 L374.53,221.69s-12.9,9.65 -9.45,13.11 3.99,2.92 1.72,5.19 -7.17,5.3 -7.22,7.28 -36.05,90.98 -36.05,90.98 4,-2 1,1 -3,5.48 -3,5.48l-14,94.52 22.74,1.34 22.26,-86.17 49.66,-80.5s4.93,71.79 5.13,76.56 3.21,-1.23 0.21,4.77 -5,2 -3,6 -7.2,85.43 -7.2,85.43h20.75L462.59,277.9S478.43,229.64 454.98,206.95Z"
android:fillColor="#2f2e41"/>
<path
android:pathData="M431.28,71.93l-32.22,-3.35 -8.35,10.84 -9.73,5.18a24.27,24.27 0,0 0,-12.81 22.96l11.37,66.12s-9.6,21.62 -3,27 -5.1,18.71 9,12 75,1 75,1l-13,-37 9.71,-36.36 1.07,-30.49a25.83,25.83 0,0 0,-18.34 -25.63l-1.36,-0.41Z"
android:fillColor="#6FBE14"/>
<path
android:pathData="M475.64,47.23c0.21,9.08 -3.18,17.88 -8.06,25.6 -1.45,-4.51 -4.05,-8.61 -6.77,-12.53a38.99,38.99 0,0 1,-4.15 24.7,5.22 5.22,0 0,1 -0.44,0.28c-3.97,2.39 -9.01,3.36 -13.31,1.63 8.88,-9.58 10.01,-25.44 2.57,-36.19 -2.11,-3.05 -4.84,-5.74 -6.14,-9.21 -2.06,-5.53 -0.08,-11.63 1.17,-17.4 1.17,-5.37 1.37,-11.76 -2.23,-15.7a3.79,3.79 0,0 1,3.47 -1.6c2.22,0.31 3.84,2.24 4.87,4.23 1.03,1.99 1.71,4.19 3.14,5.91 2.66,3.21 7.18,3.98 11,5.67C469.99,26.76 475.42,37.12 475.64,47.23Z"
android:fillColor="#2f2e41"/>
<path
android:pathData="M237.65,479.66a1.19,1.19 0,0 0,1.19 1.19h253.29a1.19,1.19 0,0 0,0 -2.38h-253.29A1.19,1.19 0,0 0,237.65 479.66Z"
android:fillColor="#ccc"/>
<path
android:pathData="M477.64,248.75m-9,0a9,9 0,1 1,18 0a9,9 0,1 1,-18 0"
android:fillColor="#BBB8EF"/>
<path
android:pathData="M397.89,42.04c0.53,-1.85 -3.11,9.45 -1.35,9.65 8,0.92 18.97,5.69 24.54,7.92 0.25,-0.03 0.5,-0.06 0.75,-0.09 0.6,-0.07 1.18,-0.16 1.76,-0.27C436.54,56.79 441.53,36.87 441.53,36.69c0,-0.9 -2.15,-25.49 -5.54,-25.86a24.96,24.96 0,0 0,-2.68 -0.15h-8.4a39.05,39.05 0,0 0,-5.27 -0.76L419.63,9.92c-16.92,-1.29 -30.25,9.02 -29.01,21.57 0.01,0.01 0.02,0.03 0.03,0.04 0.36,0.54 0.68,1.05 0.96,1.54 0.27,0.46 0.5,0.9 0.7,1.31 1.54,3.2 -2.42,7.23 0.21,7.99 3.5,1 -9.19,33.89 4.64,33.89C390.43,78.17 396.43,47.13 397.89,42.04Z"
android:fillColor="#2f2e41"/>
<path
android:pathData="M412.99,41.44m-19.89,0a19.89,19.89 0,1 1,39.79 0a19.89,19.89 0,1 1,-39.79 0"
android:fillColor="#a0616a"/>
<path
android:pathData="M390.62,32.57c0.33,0.17 0.66,0.33 0.99,0.5 0.35,0.17 0.69,0.33 1.04,0.49 6.66,3.02 12.08,3.36 15.37,-0.98a18.39,18.39 0,0 1,1.51 -6.63,10.65 10.65,0 0,0 1.76,6.63h6.62c6.82,4.53 10.33,5 5.59,19.87 -1.32,4.14 -6.57,28.25 -4.51,31.83 0.6,-0.07 6.95,-26.47 7.53,-26.58 12.97,-2.45 21.21,-23.82 20.15,-25.03a22.28,22.28 0,0 0,-2.31 -9.91,22.79 22.79,0 0,0 -8.66,-9.42 40.17,40.17 0,0 0,-6.92 -2.6c-0.06,-0.01 -0.11,-0.03 -0.17,-0.04 -0.73,-0.2 -1.48,-0.38 -2.22,-0.53a40.84,40.84 0,0 0,-4.66 -0.71c-0.11,-0.01 -0.22,-0.01 -0.32,-0.01a3.51,3.51 0,0 0,-1.78 0.49c-0.01,0 -0.01,0.01 -0.01,0.01a3.35,3.35 0,0 0,-0.99 0.88,3.39 3.39,0 0,0 -0.72,2.1L410.54,12.91q-0.41,0 -0.82,0.02a19.78,19.78 0,0 0,-19.07 18.6C390.63,31.88 390.62,32.22 390.62,32.57Z"
android:fillColor="#2f2e41"/>
<path
android:pathData="M434.12,13.11m-13.11,0a13.11,13.11 0,1 1,26.21 0a13.11,13.11 0,1 1,-26.21 0"
android:fillColor="#2f2e41"/>
<path
android:pathData="M477.74,252.46a8.25,8.25 0,0 0,-3.72 -12l0.06,-41.1 -11.36,-2.81 0.28,48.82a8.23,8.23 0,0 0,14.74 7.09Z"
android:fillColor="#a0616a"/>
<path
android:pathData="M421.46,101.48l17.68,-12.02a7.15,7.15 0,0 1,10.3 2.48l30.4,55.56 0.12,81.31 -18.98,-1.19 -7.79,-67.13Z"
android:fillColor="#66FF63"/>
<path
android:pathData="M285.65,285.88h-189a15.5,15.5 0,0 0,0 31h189a15.5,15.5 0,1 0,0 -31Z"
android:fillColor="#fff"/>
<path
android:pathData="M285.65,317.88h-189a16.5,16.5 0,0 1,0 -33h189a16.5,16.5 0,1 1,0 33ZM96.65,286.88a14.5,14.5 0,0 0,0 29h189a14.5,14.5 0,1 0,0 -29Z"
android:fillColor="#6c63ff"/>
<path
android:pathData="M296.79,353.52L213.38,353.52a4.41,4.41 0,1 1,0 -8.82h83.41a4.41,4.41 0,0 1,0 8.82Z"
android:fillColor="#6c63ff"/>
</vector>
Code to call the xml is below
Icon(painter = painterResource(id = R.drawable.passwordreset),
contentDescription = null)
I tried importing other svgs from various sources to see if there is any difference. But i get the same result.
You should use Image
instead of Icon
. If you want to use Icon
, you need to set tint
to Color.Unspecified
.
Icon(painter = painterResource(id = R.drawable.passwordreset), tint = Color.Unspecified, contentDescription = null)
Lin Htet Ko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.