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

dagomni

05/28/2020, 6:53 PM
Values declared in
group
tags inside a vector drawable are not getting applied when I load the drawable using vectorResource. Should I extract them for each drawable and apply manually using DrawLayerModifier or is it something that's getting fixed soon? 🤔
l

Leland Richardson [G]

05/28/2020, 7:03 PM
Can you give an example?
d

dagomni

05/28/2020, 8:08 PM
So far I've tested two drawables - rotation/translation is not working
Copy code
<vector xmlns:android="<http://schemas.android.com/apk/res/android>"
    android:viewportWidth="18"
    android:viewportHeight="18"
    android:width="18dp"
    android:height="18dp">
    <group
            android:rotation="45"
            android:translateX="9"
            android:translateY="-4">
    <path android:pathData="M9.5 8l8 0 0 1.5 -8 0 0 8 -1.5 0 0 -8 -8 0 0 -1.5 8 0 0 -8 1.5 0 0 8z"
            android:fillColor="#FFFFFF" />
    </group>

</vector>
Copy code
<vector xmlns:android="<http://schemas.android.com/apk/res/android>"
    android:viewportWidth="16"
    android:viewportHeight="11"
    android:width="16dp"
    android:height="11dp">
    <group
            android:translateX="-4"
            android:translateY="-7">
        <path
                android:pathData="M5.7071068 13l4.1464466 4.146447c0.1952626 0.195262 0.1952626 0.511844 0 0.707106 -0.1952622 0.195262 -0.5118446 0.195262 -0.7071068 0l-5 -5c-0.1952621 -0.195262 -0.1952621 -0.511844 0 -0.707106l5 -5.0000004c0.1952622 -0.1952621 0.5118446 -0.1952621 0.7071068 0 0.1952626 0.1952622 0.1952626 0.5118446 0 0.7071068L5.7071068 12 19.5 12c0.276142 0 0.5 0.223858 0.5 0.5 0 0.276142 -0.223858 0.5 -0.5 0.5L5.7071068 13Z"
                android:fillColor="#FFFFFF" />
    </group>
</vector>
This white line should be an arrow - no translation applied, or maybe applied incorrectly?
l

Leland Richardson [G]

05/28/2020, 8:47 PM
hmm. outside my wheelhouse. cc @Nader Jawad think you can help here?
n

Nader Jawad

05/29/2020, 2:55 AM
Hey Daniel can you share the entire composable that is consuming this vector asset? I ran this locally and can see the arrow in my demo. Also which version of compose are you testing on? I know earlier versions had some issues parsing groups that may have been addressed in a later release
👀 1
d

dagomni

05/29/2020, 9:30 AM
It happens even with plain Icon, no matter where I put it
Copy code
Icon(
    asset = vectorResource(R.drawable.icon_arrow)
)
I'm using dev11
Here's a screenshot with only this Icon in the structure and Modifier.fillMaxSize()
And here's how the drawable should look, just to clarify we're seeing the same thing
2 Views