https://kotlinlang.org logo
#compose
Title
# compose
j

Jérémy CROS

02/22/2022, 3:39 PM
Hi guys! 🙂 We’ve add a recurring issue in our application rendering svg files in compose. And it’s getting to the point where it’s a deal breaker for us. The code is fairly simple:
Copy code
Icon(
    painter = painterResource(R.drawable.ic_where_am_i_navigation),
    contentDescription = stringResource(R.string.content_description_button_where_am_i),
    tint = iconTint
)
I’ll add screenshots of the poorly drawn image in a thread. Two remarks: 1) not all our icons have the issue in compose, most are fine and 2) those “faulty” files worked perfectly in XML (using the standard
<ImageButton>
) Anything we’re missing?
Actual icon as seen in the Android Studio preview
Icon displayed in the app
svg file in case it can help:
Copy code
<vector xmlns:android="<http://schemas.android.com/apk/res/android>"
    android:width="60dp"
    android:height="59.998dp"
    android:viewportWidth="60"
    android:viewportHeight="59.998">
    <path
        android:fillColor="?attr/colorOnBackground"
        android:pathData="M30.0031,59.998a30,30 0,1 1,30 -30A30.033,30.033 0,0 1,30.0031 59.998ZM30.0031,2.4414a27.557,27.557 0,1 0,27.556 27.558A27.588,27.588 0,0 0,30.0031 2.4414Z" />
    <path
        android:fillColor="?attr/colorOnBackground"
        android:pathData="M16.178,16.2979q0.685,1.459 1.375,2.923 3.136,6.551 6.261,13.105a7.26,7.26 0,0 0,3.755 3.813c1.309,0.56 2.572,1.223 3.861,1.844q5.951,2.843 11.908,5.691c0.147,0.072 0.294,0.238 0.482,0.076a0.909,0.909 0,0 0,-0.177 -0.513q-3.843,-8.052 -7.7,-16.095a6.42,6.42 0,0 0,-3.059 -3.054q-7.246,-3.492 -14.511,-6.955c-0.685,-0.33 -1.375,-0.641 -2.065,-0.958C16.264,16.2168 16.219,16.2598 16.178,16.2979ZM34.3669,30.0068a4.358,4.358 0,0 1,-4.409 4.445,4.428 4.428,0 0,1 0.031,-8.854A4.336,4.336 0,0 1,34.3671 30.0068Z" />
    <path
        android:fillColor="?attr/colorOnBackground"
        android:pathData="M30,54.4648l-2.549,4.414h5.1Z" />
    <path
        android:fillColor="?attr/colorOnBackground"
        android:pathData="M30,5.2725l2.549,-4.414h-5.1Z" />
    <path
        android:fillColor="?attr/colorOnBackground"
        android:pathData="M54.5959,29.9998l4.415,2.548v-5.1Z" />
    <path
        android:fillColor="?attr/colorOnBackground"
        android:pathData="M5.4019,29.9998l-4.415,-2.549v5.1Z" />
</vector>
a

Adam Powell

02/22/2022, 3:49 PM
Looks like you have a solid repro case, can you file it on the issue tracker if you still see this same behavior using the latest alphas? cc @Nader Jawad
j

Jérémy CROS

02/22/2022, 4:59 PM
Checking the very last version of the libs...Damn it, how was this not the very first thing to try on our end? 😫 Obviously, it did the trick and our images are now properly displayed 🎉 Thing is, I think did a full update of compose versions about a couple months ago so it did not cross my mind to check again... You guys are moving too fast haha 😄 Anyway, thanks @Adam Powell, it was an easy suggestion but it helped us a great deal 🙏
👍 3
a

Adam Powell

02/22/2022, 5:07 PM
glad it helped; tbh the suggestion was a bit of a longshot on my part 😅
😄 1